From: Adrian Szyndela Date: Wed, 29 May 2019 09:38:33 +0000 (+0200) Subject: tests: add 'worst case' performance test X-Git-Tag: accepted/tizen/unified/20190627.014814~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1b9f86c623aa2dd00b9ca3842cc9a01c224f4416;p=platform%2Fcore%2Fsystem%2Flibdbuspolicy.git tests: add 'worst case' performance test Change-Id: I4d14eeb5bea1e7054674793ebd8d0861c876eb59 --- diff --git a/src/stest_performance.cpp b/src/stest_performance.cpp index 2f1c643..bbb60a7 100644 --- a/src/stest_performance.cpp +++ b/src/stest_performance.cpp @@ -145,13 +145,18 @@ struct Test tests[]={ TC(Decision::ALLOW, "org.tizen.test.dest_prefix.do org.tizen.test.dest_prefix.ao.ao"), }; +struct Test test_send_to_nonexistent[]={ + {Decision::DENY, ROOT, ROOT, "User::Shell", "no.such.destination", "/no/such/path", + "no.such.interface", "no_such_method", ldp_xml_parser::MessageType::METHOD_CALL} +}; + void test_print(const struct Test* t, Decision result) { printf("uid = %lu, gid = %lu, label = %s, destination = %s, expected = %s, result = %s", (unsigned long)t->user, (unsigned long)t->group, t->label, t->destination, DECISIONS[t->expected_result], DECISIONS[result]); } -template -void send_prefix_test(const DB &db) +template +void send_prefix_test(const DB &db, const Array &tests) { for (const auto &test : tests) { KdbusBusNames names; @@ -180,7 +185,7 @@ void run_x_times(std::function func, size_t times) { std::cout << "run: " << static_cast(end - begin)/CLOCKS_PER_SEC << std::endl; } -void run_fb(const char *conf_file, bool verify, size_t count) { +void run_fb(const char *conf_file, bool verify, size_t count, bool worst) { Serializer serializer; size_t size; uint8_t *buff = serializer.serialize(conf_file, size); @@ -199,11 +204,14 @@ void run_fb(const char *conf_file, bool verify, size_t count) { storage.init(file); printf("FLATBUFFERS:\n"); - run_x_times([&storage](){ send_prefix_test(storage); }, count); + if (!worst) + run_x_times([&storage](){ send_prefix_test(storage, tests); }, count); + else + run_x_times([&storage](){ send_prefix_test(storage, test_send_to_nonexistent); }, count); } -void run_tests(const char *conf_file, bool verify, size_t c) { - run_fb(conf_file, verify, c); +void run_tests(const char *conf_file, bool verify, size_t c, bool worst) { + run_fb(conf_file, verify, c, worst); } void print_help(const char *name) { @@ -216,7 +224,8 @@ void print_help(const char *name) { static const struct option options[] { {"system", no_argument, 0, 0}, - {"session", no_argument, 0, 0} + {"session", no_argument, 0, 0}, + {nullptr, 0, nullptr, 0} }; int main(int argc, char *argv[]) @@ -225,10 +234,11 @@ int main(int argc, char *argv[]) std::string input_filename = system_bus_conf_file_primary(); size_t count = 100; bool verify = false; + bool worst = false; while (1) { int option_index; - c = getopt_long(argc, argv, "vc:", options, &option_index); + c = getopt_long(argc, argv, "vwc:", options, &option_index); if (c == -1) break; switch(c) { @@ -242,6 +252,9 @@ int main(int argc, char *argv[]) case 'v': verify = true; break; + case 'w': + worst = true; + break; } } @@ -253,7 +266,7 @@ int main(int argc, char *argv[]) } tslog::init(); - run_tests(input_filename.c_str(), verify, count); + run_tests(input_filename.c_str(), verify, count, worst); return 0; }