mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
a7a8778dcf
Summary: This simplifies a handful of tests and will make writing the READDIR RPC a bit less magic when computing the amount of memory needed per entry. Reviewed By: chadaustin Differential Revision: D26802312 fbshipit-source-id: fc66cb68f721ed34c8f9879cdda2cd8db6ed8daa
49 lines
1.0 KiB
C++
49 lines
1.0 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#ifndef _WIN32
|
|
|
|
#include "eden/fs/nfs/NfsdRpc.h"
|
|
#include <gtest/gtest.h>
|
|
#include "eden/fs/nfs/testharness/XdrTestUtils.h"
|
|
|
|
namespace facebook::eden {
|
|
|
|
struct ResOk {
|
|
int a;
|
|
};
|
|
EDEN_XDR_SERDE_DECL(ResOk, a);
|
|
EDEN_XDR_SERDE_IMPL(ResOk, a);
|
|
|
|
struct ResFail {
|
|
int b;
|
|
};
|
|
EDEN_XDR_SERDE_DECL(ResFail, b);
|
|
EDEN_XDR_SERDE_IMPL(ResFail, b);
|
|
|
|
struct FullVariant : public detail::Nfsstat3Variant<ResOk, ResFail> {};
|
|
|
|
struct EmptyFailVariant : public detail::Nfsstat3Variant<ResOk> {};
|
|
|
|
TEST(NfsdRpcTest, variant) {
|
|
FullVariant var1{{{nfsstat3::NFS3_OK, ResOk{42}}}};
|
|
roundtrip(var1);
|
|
|
|
FullVariant var2{{{nfsstat3::NFS3ERR_PERM, ResFail{10}}}};
|
|
roundtrip(var2);
|
|
|
|
EmptyFailVariant var3{{{nfsstat3::NFS3_OK, ResOk{42}}}};
|
|
roundtrip(var3);
|
|
|
|
EmptyFailVariant var4{{{nfsstat3::NFS3ERR_PERM, std::monostate{}}}};
|
|
roundtrip(var4);
|
|
}
|
|
|
|
} // namespace facebook::eden
|
|
|
|
#endif
|