Generate serial number randomly in VTS unit test
Any fixed integer can be returned by vendor's APIs response.
Ideally it should be a random value for testing a vendor library.
Applying this to all the unit tests serial number.
Cherry-pick from:
https://googleplex-android-review.git.corp.google.com/#/c/2330821/
Bug: 38499889
Test: adb shell data/local/tmp/VtsHalRadioV1_0TargetTest
Change-Id: I491db829cca607fad9f6a21987de92269d115253
Merged-In: I491db829cca607fad9f6a21987de92269d115253
(cherry picked from commit 0e8a3be41c7c0b0a8de9740524b8cac49c685c99)
diff --git a/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp b/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp
index e7c89d5..59881ef 100644
--- a/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp
+++ b/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp
@@ -17,11 +17,16 @@
#include <radio_hidl_hal_utils.h>
int main(int argc, char** argv) {
- ::testing::AddGlobalTestEnvironment(new RadioHidlEnvironment);
- ::testing::InitGoogleTest(&argc, argv);
+ ::testing::AddGlobalTestEnvironment(new RadioHidlEnvironment);
+ ::testing::InitGoogleTest(&argc, argv);
- int status = RUN_ALL_TESTS();
- LOG(INFO) << "Test result = " << status;
+ // setup seed for rand function
+ int seedSrand = time(NULL);
+ std::cout << "seed setup for random function (radio):" + std::to_string(seedSrand) << std::endl;
+ srand(seedSrand);
- return status;
+ int status = RUN_ALL_TESTS();
+ LOG(INFO) << "Test result = " << status;
+
+ return status;
}
\ No newline at end of file