diff options
-rwxr-xr-x | buildscripts/runandroidsim.sh | 40 | ||||
-rwxr-xr-x | buildscripts/runiossim.sh | 15 | ||||
-rw-r--r-- | src/mongo/client/embedded/embedded_transport_layer_test.cpp | 1 | ||||
-rw-r--r-- | src/mongo/client/embedded/libmongodbcapi_test.cpp | 121 |
4 files changed, 100 insertions, 77 deletions
diff --git a/buildscripts/runandroidsim.sh b/buildscripts/runandroidsim.sh index 49038786b76..458cd93c2f8 100755 --- a/buildscripts/runandroidsim.sh +++ b/buildscripts/runandroidsim.sh @@ -20,28 +20,46 @@ shift EMULATOR_PID='' cleanup() { - kill $EMULATOR_PID - wait $EMULATOR_PID - $ANDROID_SDK/tools/bin/avdmanager delete avd -n android_avd -} + echo "Cleanup handler invoked" + + if [ -z "$EMULATOR_PID" ]; then + echo "No EMULATOR_PID found; not killing" + else + echo "Killing emulator" + kill $EMULATOR_PID || true -trap cleanup EXIT + echo "Waiting for emulator to shut down" + wait $EMULATOR_PID || true + fi -# create a virtual device + echo "Deleting the virtual device" + $ANDROID_SDK/tools/bin/avdmanager delete avd -n android_avd || true + + echo "Exiting with status $1" + exit $1 +} + +echo "Creating Android virtual device" echo no | $ANDROID_SDK/tools/bin/avdmanager create avd --force -k "system-images;android-24;google_apis;$ANDROID_SYSTEM_IMAGE_ARCH" --name android_avd --abi google_apis/$ANDROID_SYSTEM_IMAGE_ARCH -p android_avd -# start the device on the emulator +trap 'cleanup $?' INT TERM EXIT + +echo "Starting the virtual device on the emulator" $ANDROID_SDK/emulator/emulator @android_avd -no-window -no-audio & EMULATOR_PID=$! -#wait for the adb service to be ready for commands +echo "Waiting for the adb service to be ready for commands" $ANDROID_SDK/platform-tools/adb wait-for-device -#have the adb service become root +echo "Making the adb service become root" $ANDROID_SDK/platform-tools/adb root -#move the test to the device +echo "Copying the test to the virtual device" $ANDROID_SDK/platform-tools/adb push $DIRECTORY /data -#run the device +echo "Running the test on the virtual device" $ANDROID_SDK/platform-tools/adb shell /data/$(basename $DIRECTORY)/$TEST_PATH_IN_DIRECTORY "$@" + +# Do not add additional statements after the above adb invocation without +# forwarding its exit status or you will cause failing tests to appear +# to succeed. diff --git a/buildscripts/runiossim.sh b/buildscripts/runiossim.sh index 73cfe8ffe28..77e0be6b75d 100755 --- a/buildscripts/runiossim.sh +++ b/buildscripts/runiossim.sh @@ -25,23 +25,30 @@ shift cleanup() { echo "Shutting down simulator" - xcrun simctl shutdown $_SimId + xcrun simctl shutdown $_SimId || true echo "Erasing simulator" - xcrun simctl erase $_SimId + xcrun simctl erase $_SimId || true echo "Deleting simulator" - xcrun simctl delete $_SimId + xcrun simctl delete $_SimId || true + + echo "Exiting with status $1" + exit $1 } echo "Creating simulator" _SimId=$(xcrun simctl create mongodb-simulator-$DEVICE.$RUNTIME "com.apple.CoreSimulator.SimDeviceType.$DEVICE" "com.apple.CoreSimulator.SimRuntime.$RUNTIME") echo "Simulator created with ID $_SimId" -trap cleanup EXIT +trap 'cleanup $?' INT TERM EXIT echo "Booting simulator" xcrun simctl boot $_SimId echo "Spawning test program in simulator" xcrun simctl spawn $_SimId "$TEST" "$@" + +# Do not add additional statements after the above spawn without +# forwarding its exit status or you will cause failing tests to appear +# to succeed. diff --git a/src/mongo/client/embedded/embedded_transport_layer_test.cpp b/src/mongo/client/embedded/embedded_transport_layer_test.cpp index f0ec982eee8..a256cb75f32 100644 --- a/src/mongo/client/embedded/embedded_transport_layer_test.cpp +++ b/src/mongo/client/embedded/embedded_transport_layer_test.cpp @@ -221,7 +221,6 @@ int main(int argc, char** argv, char** envp) { } mongoc_cleanup(); - globalTempDir.reset(); mongo::quickExit(result); } diff --git a/src/mongo/client/embedded/libmongodbcapi_test.cpp b/src/mongo/client/embedded/libmongodbcapi_test.cpp index 574bec94be2..df780bbe265 100644 --- a/src/mongo/client/embedded/libmongodbcapi_test.cpp +++ b/src/mongo/client/embedded/libmongodbcapi_test.cpp @@ -521,66 +521,64 @@ TEST_F(MongodbCAPITest, InsertAndUpdate) { TEST_F(MongodbCAPITest, RunListCommands) { auto client = createClient(); - std::vector<std::string> whitelist = { - "_hashBSONElement", - "aggregate", - "buildInfo", - "cloneCollectionAsCapped", - "collMod", - "collStats", - "configureFailPoint", - "convertToCapped", - "count", - "create", - "createIndexes", - "currentOp", - "dataSize", - "dbStats", - "delete", - "distinct", - "drop", - "dropDatabase", - "dropIndexes", - "echo", - "explain", - "find", - "findAndModify", - "geoNear", - "getLastError", - "getMore", - "getParameter", - "getPrevError", - "getShardMap", - "insert", - "isMaster", - "killCursors", - "killOp", - "listCollections", - "listCommands", - "listDatabases", - "listIndexes", - "lockInfo", - "logApplicationMessage", // TODO: See whether we need this command - "ping", - "planCacheClear", - "planCacheClearFilters", - "planCacheListFilters", - "planCacheListPlans", - "planCacheListQueryShapes", - "planCacheSetFilter", - "reIndex", - "renameCollection", - "repairCursor", - "repairDatabase", - "replSetGetStatus", - "resetError", - "serverStatus", - "setBatteryLevel", - "setParameter", - "sleep", - "trimMemory", - "update", - "validate"}; + std::vector<std::string> whitelist = {"_hashBSONElement", + "aggregate", + "buildInfo", + "cloneCollectionAsCapped", + "collMod", + "collStats", + "configureFailPoint", + "convertToCapped", + "count", + "create", + "createIndexes", + "currentOp", + "dataSize", + "dbStats", + "delete", + "distinct", + "drop", + "dropDatabase", + "dropIndexes", + "echo", + "explain", + "find", + "findAndModify", + "geoNear", + "getLastError", + "getMore", + "getParameter", + "getPrevError", + "getShardMap", + "insert", + "isMaster", + "killCursors", + "killOp", + "listCollections", + "listCommands", + "listDatabases", + "listIndexes", + "lockInfo", + "ping", + "planCacheClear", + "planCacheClearFilters", + "planCacheListFilters", + "planCacheListPlans", + "planCacheListQueryShapes", + "planCacheSetFilter", + "reIndex", + "renameCollection", + "repairCursor", + "repairDatabase", + "replSetGetStatus", + "resetError", + "serverStatus", + "setBatteryLevel", + "setParameter", + "sleep", + "trimMemory", + "update", + "validate"}; std::sort(whitelist.begin(), whitelist.end()); mongo::BSONObj listCommandsObj = mongo::fromjson("{ listCommands: 1 }"); @@ -716,7 +714,8 @@ int main(const int argc, const char* const* const argv) { std::cerr << "Did not get a log callback." << std::endl; } - ::mongo::unittest::Suite::run(std::vector<std::string>(), "", 1); + const auto result = ::mongo::unittest::Suite::run(std::vector<std::string>(), "", 1); globalTempDir.reset(); + mongo::quickExit(result); } |