]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/bench_log: add usage function
authorchenxuqiang <chenxuqiang3@hisilicon.com>
Tue, 19 Nov 2019 14:04:12 +0000 (22:04 +0800)
committerluo rixin <luorixin@huawei.com>
Wed, 20 Nov 2019 03:05:37 +0000 (11:05 +0800)
Currently, the bench_log does not have a usage function, so that when it is used, if no pararmeters are given, a segmentation error will occur. This causes confusion.

Now, we add the usage function and add (argc < 3) conditional judgment.

Signed-off-by: Xuqiang Chen <chenxuqiang3@hisilicon.com>
src/test/bench_log.cc

index 2acbf1de48d83f1de56493be9fab46416aef7dcf..205dfe97b622598f2cb7451bad7780f50eb8e8c8 100644 (file)
@@ -30,8 +30,19 @@ struct T : public Thread {
   }
 };
 
+void usage(const char *name) {
+  cout << name << " <threads> <lines>\n"
+       << "\t threads: the number of threads for this test.\n"
+       << "\t lines: the number of log entries per thread.\n";
+}
+
 int main(int argc, const char **argv)
 {
+  if (argc < 3) {
+    usage(argv[0]);
+    return EXIT_FAILURE;
+  }
+
   int threads = atoi(argv[1]);
   int num = atoi(argv[2]);