#include <cstdlib>
#include <ctime>
+#include <memory>
#include <vector>
#include <unistd.h>
}
}
+static void help(void)
+{
+ LOG << "system_info_init_db_test [OPTION]" << ENDL;
+ LOG << " -o Test RO DB (create, insert, modify)" << ENDL;
+ LOG << " -w Test RW DB (create)" << ENDL;
+ LOG << "NOTICE : you can choose only one option" << ENDL;
+}
+
int main(int argc, char *argv[])
{
int ret;
+ int opt;
+ int optCount = 0;
+
+ std::vector<std::unique_ptr<Tester>> testerList;
+ auto addTest = [&testerList](Tester *test) {
+ testerList.push_back(std::unique_ptr<Tester>(test));
+ };
+
+ while ((opt = getopt(argc, argv, "ow")) != -1) {
+ if (++optCount > 1) {
+ help();
+ return EINVAL;
+ }
+
+ switch (opt) {
+ case 'o':
+ addTest(new CreateDB());
+ addTest(new InsertKey());
+ addTest(new ModifyValue());
+ addTest(new VerifyValue());
+ break;
+ case 'w':
+ addTest(new CreateRWDB());
+ addTest(new VerifyValue());
+ break;
+ default:
+ help();
+ return EINVAL;
+ }
+ }
+
+ if (testerList.empty()) {
+ help();
+ return EINVAL;
+ }
LOG << "========== Start system_info_init_db test ==========" << ENDL << ENDL;
return ret;
}
- Tester *testerList[] = {
- new CreateDB(),
- new InsertKey(),
- new ModifyValue(),
- new VerifyValue(),
- new CreateRWDB(),
- };
-
- for (auto tester : testerList) {
+ for (auto &tester : testerList)
tester->test();
- delete(tester);
- }
finalize();