Commit dec098cc authored by Kenton Varda's avatar Kenton Varda

Update mega-test, and make tests pass.

parent 3b60a4cb
......@@ -2218,6 +2218,7 @@ private:
" switch (methodId) {\n",
KJ_MAP(m, methods) { return kj::mv(m.dispatchCase); },
" default:\n"
" (void)context;\n"
" return ::capnp::Capability::Server::internalUnimplemented(\n"
" \"", proto.getDisplayName(), "\",\n"
" 0x", kj::hex(proto.getId()), "ull, methodId);\n"
......
......@@ -893,6 +893,18 @@ TEST(Rpc, Embargo) {
EXPECT_EQ(5, call5.wait(context.waitScope).getN());
}
template <typename T>
void expectPromiseThrows(kj::Promise<T>&& promise, kj::WaitScope& waitScope) {
EXPECT_TRUE(promise.then([](T&&) { return false; }, [](kj::Exception&&) { return true; })
.wait(waitScope));
}
template <>
void expectPromiseThrows(kj::Promise<void>&& promise, kj::WaitScope& waitScope) {
EXPECT_TRUE(promise.then([]() { return false; }, [](kj::Exception&&) { return true; })
.wait(waitScope));
}
TEST(Rpc, EmbargoError) {
TestContext context;
......@@ -924,14 +936,14 @@ TEST(Rpc, EmbargoError) {
auto call4 = getCallSequence(pipeline, 4);
auto call5 = getCallSequence(pipeline, 5);
paf.fulfiller->rejectIfThrows([]() { KJ_FAIL_ASSERT("foo"); });
paf.fulfiller->rejectIfThrows([]() { KJ_FAIL_ASSERT("foo") { break; } });
EXPECT_ANY_THROW(call0.wait(context.waitScope));
EXPECT_ANY_THROW(call1.wait(context.waitScope));
EXPECT_ANY_THROW(call2.wait(context.waitScope));
EXPECT_ANY_THROW(call3.wait(context.waitScope));
EXPECT_ANY_THROW(call4.wait(context.waitScope));
EXPECT_ANY_THROW(call5.wait(context.waitScope));
expectPromiseThrows(kj::mv(call0), context.waitScope);
expectPromiseThrows(kj::mv(call1), context.waitScope);
expectPromiseThrows(kj::mv(call2), context.waitScope);
expectPromiseThrows(kj::mv(call3), context.waitScope);
expectPromiseThrows(kj::mv(call4), context.waitScope);
expectPromiseThrows(kj::mv(call5), context.waitScope);
// Verify that we're still connected (there were no protocol errors).
getCallSequence(client, 1).wait(context.waitScope);
......@@ -972,9 +984,9 @@ TEST(Rpc, CallBrokenPromise) {
EXPECT_FALSE(returned);
paf.fulfiller->rejectIfThrows([]() { KJ_FAIL_ASSERT("foo"); });
paf.fulfiller->rejectIfThrows([]() { KJ_FAIL_ASSERT("foo") { break; } });
EXPECT_ANY_THROW(req.wait(context.waitScope));
expectPromiseThrows(kj::mv(req), context.waitScope);
EXPECT_TRUE(returned);
kj::evalLater([]() {}).wait(context.waitScope);
......@@ -1020,7 +1032,7 @@ TEST(Rpc, Abort) {
typedef RealmGateway<test::TestSturdyRef, Text> TestRealmGateway;
class TestGateway: public TestRealmGateway::Server {
class TestGateway final: public TestRealmGateway::Server {
public:
kj::Promise<void> import(ImportContext context) override {
auto cap = context.getParams().getCap();
......@@ -1043,7 +1055,7 @@ public:
}
};
class TestPersistent: public Persistent<test::TestSturdyRef>::Server {
class TestPersistent final: public Persistent<test::TestSturdyRef>::Server {
public:
TestPersistent(kj::StringPtr name): name(name) {}
......@@ -1056,7 +1068,7 @@ private:
kj::StringPtr name;
};
class TestPersistentText: public Persistent<Text>::Server {
class TestPersistentText final: public Persistent<Text>::Server {
public:
TestPersistentText(kj::StringPtr name): name(name) {}
......
......@@ -36,7 +36,7 @@ TEST(Schema, Structs) {
EXPECT_TRUE(schema.getDependency(typeId<TestEnum>()) != schema);
EXPECT_TRUE(schema.getDependency(typeId<TestAllTypes>()) == Schema::from<TestAllTypes>());
EXPECT_TRUE(schema.getDependency(typeId<TestAllTypes>()) == schema);
EXPECT_ANY_THROW(schema.getDependency(typeId<TestDefaults>()));
EXPECT_NONFATAL_FAILURE(schema.getDependency(typeId<TestDefaults>()));
EXPECT_TRUE(schema.asStruct() == schema);
EXPECT_NONFATAL_FAILURE(schema.asEnum());
......@@ -122,8 +122,8 @@ TEST(Schema, Enums) {
EXPECT_EQ(typeId<TestEnum>(), schema.getProto().getId());
EXPECT_ANY_THROW(schema.getDependency(typeId<TestAllTypes>()));
EXPECT_ANY_THROW(schema.getDependency(typeId<TestEnum>()));
EXPECT_NONFATAL_FAILURE(schema.getDependency(typeId<TestAllTypes>()));
EXPECT_NONFATAL_FAILURE(schema.getDependency(typeId<TestEnum>()));
EXPECT_NONFATAL_FAILURE(schema.asStruct());
EXPECT_NONFATAL_FAILURE(schema.asInterface());
......@@ -165,27 +165,27 @@ TEST(Schema, Lists) {
EXPECT_EQ(schema::Type::TEXT, Schema::from<List<Text>>().whichElementType());
EXPECT_EQ(schema::Type::DATA, Schema::from<List<Data>>().whichElementType());
EXPECT_ANY_THROW(Schema::from<List<uint16_t>>().getStructElementType());
EXPECT_ANY_THROW(Schema::from<List<uint16_t>>().getEnumElementType());
EXPECT_ANY_THROW(Schema::from<List<uint16_t>>().getInterfaceElementType());
EXPECT_ANY_THROW(Schema::from<List<uint16_t>>().getListElementType());
EXPECT_NONFATAL_FAILURE(Schema::from<List<uint16_t>>().getStructElementType());
EXPECT_NONFATAL_FAILURE(Schema::from<List<uint16_t>>().getEnumElementType());
EXPECT_NONFATAL_FAILURE(Schema::from<List<uint16_t>>().getInterfaceElementType());
EXPECT_NONFATAL_FAILURE(Schema::from<List<uint16_t>>().getListElementType());
{
ListSchema schema = Schema::from<List<TestAllTypes>>();
EXPECT_EQ(schema::Type::STRUCT, schema.whichElementType());
EXPECT_TRUE(schema.getStructElementType() == Schema::from<TestAllTypes>());
EXPECT_ANY_THROW(schema.getEnumElementType());
EXPECT_ANY_THROW(schema.getInterfaceElementType());
EXPECT_ANY_THROW(schema.getListElementType());
EXPECT_NONFATAL_FAILURE(schema.getEnumElementType());
EXPECT_NONFATAL_FAILURE(schema.getInterfaceElementType());
EXPECT_NONFATAL_FAILURE(schema.getListElementType());
}
{
ListSchema schema = Schema::from<List<TestEnum>>();
EXPECT_EQ(schema::Type::ENUM, schema.whichElementType());
EXPECT_TRUE(schema.getEnumElementType() == Schema::from<TestEnum>());
EXPECT_ANY_THROW(schema.getStructElementType());
EXPECT_ANY_THROW(schema.getInterfaceElementType());
EXPECT_ANY_THROW(schema.getListElementType());
EXPECT_NONFATAL_FAILURE(schema.getStructElementType());
EXPECT_NONFATAL_FAILURE(schema.getInterfaceElementType());
EXPECT_NONFATAL_FAILURE(schema.getListElementType());
}
// TODO(someday): Test interfaces.
......@@ -193,9 +193,9 @@ TEST(Schema, Lists) {
{
ListSchema schema = Schema::from<List<List<int32_t>>>();
EXPECT_EQ(schema::Type::LIST, schema.whichElementType());
EXPECT_ANY_THROW(schema.getStructElementType());
EXPECT_ANY_THROW(schema.getEnumElementType());
EXPECT_ANY_THROW(schema.getInterfaceElementType());
EXPECT_NONFATAL_FAILURE(schema.getStructElementType());
EXPECT_NONFATAL_FAILURE(schema.getEnumElementType());
EXPECT_NONFATAL_FAILURE(schema.getInterfaceElementType());
ListSchema inner = schema.getListElementType();
EXPECT_EQ(schema::Type::INT32, inner.whichElementType());
......@@ -204,9 +204,9 @@ TEST(Schema, Lists) {
{
ListSchema schema = Schema::from<List<List<TestAllTypes>>>();
EXPECT_EQ(schema::Type::LIST, schema.whichElementType());
EXPECT_ANY_THROW(schema.getStructElementType());
EXPECT_ANY_THROW(schema.getEnumElementType());
EXPECT_ANY_THROW(schema.getInterfaceElementType());
EXPECT_NONFATAL_FAILURE(schema.getStructElementType());
EXPECT_NONFATAL_FAILURE(schema.getEnumElementType());
EXPECT_NONFATAL_FAILURE(schema.getInterfaceElementType());
ListSchema inner = schema.getListElementType();
EXPECT_EQ(schema::Type::STRUCT, inner.whichElementType());
......@@ -216,9 +216,9 @@ TEST(Schema, Lists) {
{
ListSchema schema = Schema::from<List<List<TestEnum>>>();
EXPECT_EQ(schema::Type::LIST, schema.whichElementType());
EXPECT_ANY_THROW(schema.getStructElementType());
EXPECT_ANY_THROW(schema.getEnumElementType());
EXPECT_ANY_THROW(schema.getInterfaceElementType());
EXPECT_NONFATAL_FAILURE(schema.getStructElementType());
EXPECT_NONFATAL_FAILURE(schema.getEnumElementType());
EXPECT_NONFATAL_FAILURE(schema.getInterfaceElementType());
ListSchema inner = schema.getListElementType();
EXPECT_EQ(schema::Type::ENUM, inner.whichElementType());
......@@ -232,9 +232,9 @@ TEST(Schema, Lists) {
ListSchema schema = ListSchema::of(type.getList().getElementType(), context);
EXPECT_EQ(schema::Type::ENUM, schema.whichElementType());
EXPECT_TRUE(schema.getEnumElementType() == Schema::from<TestEnum>());
EXPECT_ANY_THROW(schema.getStructElementType());
EXPECT_ANY_THROW(schema.getInterfaceElementType());
EXPECT_ANY_THROW(schema.getListElementType());
EXPECT_NONFATAL_FAILURE(schema.getStructElementType());
EXPECT_NONFATAL_FAILURE(schema.getInterfaceElementType());
EXPECT_NONFATAL_FAILURE(schema.getListElementType());
}
}
......@@ -274,7 +274,7 @@ TEST(Schema, Interfaces) {
EXPECT_TRUE(schema.getDependency(typeId<test::TestCallOrder>()) ==
Schema::from<test::TestCallOrder>());
EXPECT_TRUE(schema.getDependency(typeId<test::TestCallOrder>()) != schema);
EXPECT_ANY_THROW(schema.getDependency(typeId<TestDefaults>()));
EXPECT_NONFATAL_FAILURE(schema.getDependency(typeId<TestDefaults>()));
EXPECT_TRUE(schema.asInterface() == schema);
EXPECT_NONFATAL_FAILURE(schema.asStruct());
......
......@@ -790,7 +790,9 @@ InterfaceSchema Type::asInterface() const {
return InterfaceSchema(Schema(schema));
}
ListSchema Type::asList() const {
KJ_REQUIRE(isList(), "Type::asList(): Not a list.");
KJ_REQUIRE(isList(), "Type::asList(): Not a list.") {
return ListSchema::of(schema::Type::VOID);
}
Type elementType = *this;
--elementType.listDepth;
return ListSchema::of(elementType);
......
......@@ -213,10 +213,11 @@ TEST(AsyncIo, Timeouts) {
Timer& timer = ioContext.provider->getTimer();
auto promise1 = timer.timeoutAfter(1 * MILLISECONDS, kj::Promise<int>(kj::NEVER_DONE));
auto promise2 = timer.timeoutAfter(1 * MILLISECONDS, kj::Promise<int>(123));
auto promise1 = timer.timeoutAfter(10 * MILLISECONDS, kj::Promise<void>(kj::NEVER_DONE));
auto promise2 = timer.timeoutAfter(100 * MILLISECONDS, kj::Promise<int>(123));
EXPECT_TRUE(kj::runCatchingExceptions([&]() { promise1.wait(ioContext.waitScope); }) != nullptr);
EXPECT_TRUE(promise1.then([]() { return false; }, [](kj::Exception&& e) { return true; })
.wait(ioContext.waitScope));
EXPECT_EQ(123, promise2.wait(ioContext.waitScope));
}
......
......@@ -115,6 +115,7 @@ struct SignalCapture {
siginfo_t siginfo;
};
#if !KJ_USE_EPOLL // on Linux we'll use signalfd
KJ_THREADLOCAL_PTR(SignalCapture) threadCapture = nullptr;
void signalHandler(int, siginfo_t* siginfo, void*) {
......@@ -124,6 +125,7 @@ void signalHandler(int, siginfo_t* siginfo, void*) {
siglongjmp(capture->jumpTo, 1);
}
}
#endif
void registerSignalHandler(int signum) {
tooLateToSetReserved = true;
......
......@@ -92,12 +92,10 @@ TEST(StdIoStream, ReadToEndOfFile) {
});
buf[6] = '\0';
KJ_IF_MAYBE(ex, e) {
ASSERT_FALSE(e == nullptr);
// Ensure that the value is still read up to the EOF.
EXPECT_STREQ("foobar", buf);
} else {
ADD_FAILURE() << "Expected exception";
}
}
} // namespace
......
......@@ -215,6 +215,7 @@ void RemovePlus(char* buffer) {
}
}
#if _WIN32
void RemoveE0(char* buffer) {
// Remove redundant leading 0's after an e, e.g. 1e012. Seems to appear on
// Windows.
......@@ -227,6 +228,7 @@ void RemoveE0(char* buffer) {
memmove(buffer + 1, buffer + 2, strlen(buffer + 2) + 1);
}
}
#endif
char* DoubleToBuffer(double value, char* buffer) {
// DBL_DIG is 15 for IEEE-754 doubles, which are used on almost all
......
linux-gcc-4.7 5952 ./super-test.sh tmpdir capnp-gcc-4.7 gcc-4.7
linux-gcc-4.9 5952 ./super-test.sh tmpdir capnp-gcc-4.9 gcc-4.9
linux-gcc-4.8 5246 ./super-test.sh tmpdir capnp-gcc-4.8 gcc-4.8
linux-clang 6039 ./super-test.sh tmpdir capnp-clang clang
mac 5758 ./super-test.sh remote beat caffeinate
mac 6422 ./super-test.sh remote beat caffeinate
cygwin 6770 ./super-test.sh remote Kenton@flashman
exotic 0 ./super-test.sh tmpdir exotic exotic
exotic 4192 ./super-test.sh tmpdir exotic exotic
......@@ -69,6 +69,9 @@ while [ $# -gt 0 ]; do
clang )
export CXX=clang++
;;
gcc-4.9 )
export CXX=g++-4.9
;;
gcc-4.8 )
export CXX=g++-4.8
;;
......@@ -123,6 +126,7 @@ while [ $# -gt 0 ]; do
doit make distclean
doit ./configure --host="$CROSS_HOST" --with-external-capnp --disable-shared CXXFLAGS='-pie -fPIE' CAPNP=./capnp-host CAPNPC_CXX=./capnpc-c++-host
doit make -j6
doit make -j6 capnp-test
echo "Starting emulator..."
......@@ -152,6 +156,7 @@ while [ $# -gt 0 ]; do
echo "Android"
echo "========================================================================="
"$0" android /home/kenton/android/android-sdk-linux /home/kenton/android/android-16 arm-linux-androideabi
exit 0
;;
clean )
rm -rf tmp-staging
......@@ -168,9 +173,12 @@ while [ $# -gt 0 ]; do
echo "commands:"
echo " test Runs tests (the default)."
echo " clang Runs tests using Clang compiler."
echo " gcc-4.7 Runs tests using gcc-4.7."
echo " gcc-4.8 Runs tests using gcc-4.8."
echo " gcc-4.9 Runs tests using gcc-4.9."
echo " remote HOST Runs tests on HOST via SSH."
echo " kenton Kenton's meta-test (uses hosts on Kenton's network)."
echo " mingw Cross-compiles to MinGW and runs tests using WINE."
echo " android Cross-compiles to Android and runs tests using emulator."
echo " clean Delete temporary files that may be left after failure."
echo " help Prints this help text."
exit 0
......@@ -189,7 +197,7 @@ done
# because GCC warns about code that I know is OK. Disable sign-compare because I've fixed more
# sign-compare warnings than probably all other warnings combined and I've never seen it flag a
# real problem.
export CXXFLAGS="-O2 -DDEBUG -Wall -Werror -Wno-strict-aliasing -Wno-sign-compare"
export CXXFLAGS="-O2 -DDEBUG -Wall -Werror -Wno-strict-aliasing -Wno-sign-compare -Wno-deprecated-declarations"
STAGING=$PWD/tmp-staging
......@@ -312,6 +320,7 @@ if [ "x`uname -m`" = "xx86_64" ]; then
# Build as if we are cross-compiling, using the capnp we installed to $STAGING.
doit ./configure --prefix="$STAGING" --disable-shared --host=i686-pc-cygwin \
--with-external-capnp CAPNP=$STAGING/bin/capnp
doit make -j6
doit make -j6 capnp-test.exe
# Expect a cygwin32 sshd to be listening at localhost port 2222, and use it
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment