ref: 4ebf8266a1f69f841748f49912f7a23fd6c74260
parent: 00d0180f26f437319ac9f74b3c8a5777058e78d4
parent: df16cd9d0c3c73added0d06dde93af1789ad8c8f
author: dongzha <[email protected]>
date: Thu Aug 7 06:09:47 EDT 2014
Merge pull request #1247 from mstorsjo/test-seed Print the random seed at startup
--- a/test/api/simple_test.cpp
+++ b/test/api/simple_test.cpp
@@ -1,9 +1,8 @@
#include <gtest/gtest.h>
#include <stdlib.h>
#include <time.h>
-#if defined (ANDROID_NDK)
#include <stdio.h>
-#endif
+#include <string.h>
#if (defined(ANDROID_NDK)||defined(APPLE_IOS))
@@ -17,8 +16,12 @@
sprintf (xmlPath, "xml:%s", argv[1]);
::testing::GTEST_FLAG (output) = xmlPath;
#endif
- srand ((unsigned int)time (NULL));
::testing::InitGoogleTest (&argc, argv);
+ unsigned int seed = (unsigned int) time (NULL);
+ if (argc >= 2 && !strncmp (argv[1], "--seed=", 7))
+ seed = atoi (argv[1] + 7);
+ printf ("Random seed: %u\n", seed);
+ srand (seed);
return RUN_ALL_TESTS();
}