1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <stdio.h>
17 #include <string.h>
18 #include "hdf_base.h"
19 #include "hdf_log.h"
20 #include "usb_dev_test.h"
21 
22 #define OPTION_LENGTH 2
23 
ShowUsage(void)24 static void ShowUsage(void)
25 {
26     printf("Usage options:\n");
27     printf("-1 : AcmTest\n");
28     printf("-2 : PropTest\n");
29     printf("-3 : AcmSpeedRead\n");
30     printf("-4 : AcmSpeedWrite\n");
31     printf("-h : show usage\n");
32 }
33 
main(int32_t argc,char * argv[])34 int32_t main(int32_t argc, char *argv[])
35 {
36     if (argc < OPTION_LENGTH) {
37         printf("argv too flew\n");
38         HDF_LOGE("%{public}s:%{public}d argc=%{public}d is too flew!", __func__, __LINE__, argc);
39         return -1;
40     }
41     const char **arg = (const char **)&argv[1];
42     if (strcmp(arg[0], "-1") == 0) {
43         AcmTest(argc - 1, arg);
44     } else if (strcmp(arg[0], "-2") == 0) {
45         PropTest(argc - 1, arg);
46     } else if (strcmp(arg[0], "-3") == 0) {
47         AcmSpeedRead(argc - 1, arg);
48     } else if (strcmp(arg[0], "-4") == 0) {
49         AcmSpeedWrite(argc - 1, arg);
50     } else if (strcmp(arg[0], "-h") == 0 || \
51         strcmp(arg[0], "?") == 0) {
52         ShowUsage();
53     } else {
54         printf("unknown cmd\n");
55     }
56     return 0;
57 }
58