Changeset 88983 in vbox for trunk/src/VBox/ValidationKit/utils/audio
- Timestamp:
- May 11, 2021 1:47:16 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp
r88967 r88983 152 152 * Global Variables * 153 153 *********************************************************************************************************************************/ 154 /** 155 * Enumeration of test ("test") command line parameters. 156 */ 154 157 enum 155 158 { … … 166 169 }; 167 170 168 #if 0 171 /** 172 * Enumeration of verification ("verify") command line parameters. 173 */ 174 enum 175 { 176 VKAT_VERIFY_OPT_TAG = 900 177 }; 178 179 /** 180 * Common command line parameters. 181 */ 169 182 static const RTGETOPTDEF g_aCmdCommonOptions[] = 170 183 { 171 { "--help", 'h', RTGETOPT_REQ_NOTHING } 184 { "--help", 'h', RTGETOPT_REQ_NOTHING }, 185 { "--verbose", 'v', RTGETOPT_REQ_NOTHING } 172 186 }; 173 #endif 174 175 /** Command line parameters for test mode. */ 187 188 /** 189 * Command line parameters for test mode. 190 */ 176 191 static const RTGETOPTDEF g_aCmdTestOptions[] = 177 192 { … … 190 205 { "--tag", VKAT_TEST_OPT_TAG, RTGETOPT_REQ_STRING }, 191 206 { "--volume", VKAT_TEST_OPT_VOL, RTGETOPT_REQ_UINT8 } 192 207 }; 208 209 /** 210 * Command line parameters for verification mode. 211 */ 212 static const RTGETOPTDEF g_aCmdVerifyOptions[] = 213 { 214 { "--tag", VKAT_VERIFY_OPT_TAG, RTGETOPT_REQ_STRING } 193 215 }; 194 216 … … 197 219 /** The driver instance data. */ 198 220 PDMDRVINS g_DrvIns; 199 221 /** The current verbosity level. */ 222 unsigned g_uVerbosity = 0; 200 223 201 224 /********************************************************************************************************************************* … … 605 628 * @param argv argv arguments. 606 629 */ 607 int mainTest(int argc, char **argv)630 int audioTestMain(int argc, char **argv) 608 631 { 609 632 int rc; … … 621 644 RTGETOPTUNION ValueUnion; 622 645 RTGETOPTSTATE GetState; 623 RTGetOptInit(&GetState, argc, argv, g_aCmdTestOptions, RT_ELEMENTS(g_aCmdTestOptions), 0, 0 /* fFlags */); 646 rc = RTGetOptInit(&GetState, argc, argv, g_aCmdTestOptions, RT_ELEMENTS(g_aCmdTestOptions), 0, 0 /* fFlags */); 647 AssertRCReturn(rc, RTEXITCODE_INIT); 648 624 649 while ((rc = RTGetOpt(&GetState, &ValueUnion))) 625 650 { … … 810 835 811 836 /** 837 * Verifies one single test set. 838 * 839 * @returns VBox status code. 840 * @param pszPath Absolute path to test set. 841 * @param pszTag Tag of test set to verify. Optional and can be NULL. 842 */ 843 int audioVerifyOne(const char *pszPath, const char *pszTag) 844 { 845 RTTestSubF(g_hTest, "Verifying test set (tag '%s') ...", pszTag ? pszTag : "<Default>"); 846 847 AUDIOTESTSET tstSet; 848 int rc = AudioTestSetOpen(&tstSet, pszPath); 849 if (RT_SUCCESS(rc)) 850 { 851 rc = AudioTestSetVerify(&tstSet, pszTag); 852 if (RT_SUCCESS(rc)) 853 { 854 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Verification successful"); 855 } 856 else 857 RTTestFailed(g_hTest, "Verification failed with %Rrc", rc); 858 859 AudioTestSetClose(&tstSet); 860 } 861 else 862 RTTestFailed(g_hTest, "Opening test set '%s' (tag '%s') failed, rc=%Rrc\n", pszPath, pszTag, rc); 863 864 RTTestSubDone(g_hTest); 865 866 return rc; 867 } 868 869 /** 812 870 * Main (entry) function for the verification functionality of VKAT. 813 871 * … … 816 874 * @param argv argv arguments. 817 875 */ 818 int mainVerify(int argc, char **argv) 819 { 820 RT_NOREF(argc, argv); 821 822 return RTMsgErrorExit(RTEXITCODE_SKIPPED, "Sorry, not implemented yet!\n"); 876 int audioVerifyMain(int argc, char **argv) 877 { 878 char *pszTag = NULL; /* Custom tag to use. Can be NULL if not being used. */ 879 880 char szDirCur[RTPATH_MAX]; 881 int rc = RTPathGetCurrent(szDirCur, sizeof(szDirCur)); 882 if (RT_FAILURE(rc)) 883 { 884 RTMsgError("Getting current directory failed, rc=%Rrc\n", rc); 885 return RTEXITCODE_FAILURE; 886 } 887 888 /* 889 * Process common options. 890 */ 891 RTGETOPTUNION ValueUnion; 892 RTGETOPTSTATE GetState; 893 rc = RTGetOptInit(&GetState, argc, argv, g_aCmdVerifyOptions, RT_ELEMENTS(g_aCmdVerifyOptions), 894 0, RTGETOPTINIT_FLAGS_OPTS_FIRST); 895 AssertRCReturn(rc, RTEXITCODE_INIT); 896 897 while ((rc = RTGetOpt(&GetState, &ValueUnion))) 898 { 899 switch (rc) 900 { 901 case VKAT_VERIFY_OPT_TAG: 902 { 903 pszTag = RTStrDup(ValueUnion.psz); 904 break; 905 } 906 907 case VINF_GETOPT_NOT_OPTION: 908 { 909 Assert(GetState.iNext); 910 GetState.iNext--; 911 break; 912 } 913 914 default: 915 return RTGetOptPrintError(rc, &ValueUnion); 916 } 917 918 /* All flags / options processed? Bail out here. 919 * Processing the file / directory list comes down below. */ 920 if (rc == VINF_GETOPT_NOT_OPTION) 921 break; 922 } 923 924 if (pszTag) 925 RTMsgInfo("Using tag '%s'\n", pszTag); 926 927 /* 928 * Start testing. 929 */ 930 RTTestBanner(g_hTest); 931 932 /* 933 * Deal with test sets. 934 */ 935 rc = RTGetOpt(&GetState, &ValueUnion); 936 do 937 { 938 char const *pszPath; 939 940 if (rc == 0) /* Use current directory if no element specified. */ 941 pszPath = szDirCur; 942 else 943 pszPath = ValueUnion.psz; 944 945 RTFSOBJINFO objInfo; 946 rc = RTPathQueryInfoEx(pszPath, &objInfo, 947 RTFSOBJATTRADD_UNIX, RTPATH_F_FOLLOW_LINK); 948 if (RT_SUCCESS(rc)) 949 { 950 rc = audioVerifyOne(pszPath, pszTag); 951 } 952 else 953 RTTestFailed(g_hTest, "Cannot access path '%s', rc=%Rrc\n", pszPath, rc); 954 955 } while ((rc = RTGetOpt(&GetState, &ValueUnion)) != 0); 956 957 RTStrFree(pszTag); 958 959 /* 960 * Print summary and exit. 961 */ 962 return RTTestSummaryAndDestroy(g_hTest); 823 963 } 824 964 … … 832 972 return rc; 833 973 974 /* At least the operation mode must be there. */ 834 975 if (argc < 2) 835 976 { … … 838 979 } 839 980 840 const char *pszMode = argv[1]; 841 842 argc -= 2; 843 argv += 2; 981 /* 982 * Process common options. 983 */ 984 RTGETOPTUNION ValueUnion; 985 RTGETOPTSTATE GetState; 986 rc = RTGetOptInit(&GetState, argc, argv, g_aCmdCommonOptions, RT_ELEMENTS(g_aCmdCommonOptions), 1 /* idxFirst */, 0 /* fFlags */); 987 AssertRCReturn(rc, RTEXITCODE_INIT); 988 989 while ((rc = RTGetOpt(&GetState, &ValueUnion))) 990 { 991 switch (rc) 992 { 993 case 'h': 994 { 995 audioTestUsage(g_pStdOut); 996 return RTEXITCODE_SUCCESS; 997 } 998 999 case 'v': 1000 { 1001 g_uVerbosity++; 1002 break; 1003 } 1004 1005 case VINF_GETOPT_NOT_OPTION: 1006 { 1007 Assert(GetState.iNext); 1008 GetState.iNext--; 1009 } 1010 1011 default: 1012 /* Ignore everything else here. */ 1013 break; 1014 } 1015 1016 /* All flags / options processed? Bail out here. 1017 * Processing the file / directory list comes down below. */ 1018 if (rc == VINF_GETOPT_NOT_OPTION) 1019 break; 1020 } 1021 1022 /* Get operation mode. */ 1023 const char *pszMode = argv[GetState.iNext++]; /** @todo Also do it busybox-like? */ 1024 1025 argv += GetState.iNext; 1026 Assert(argc >= GetState.iNext); 1027 argc -= GetState.iNext; 844 1028 845 1029 if (!RTStrICmp(pszMode, "test")) 846 1030 { 847 return mainTest(argc, argv);1031 return audioTestMain(argc, argv); 848 1032 } 849 1033 else if (!RTStrICmp(pszMode, "verify")) 850 1034 { 851 return mainVerify(argc, argv);1035 return audioVerifyMain(argc, argv); 852 1036 } 853 1037
Note:
See TracChangeset
for help on using the changeset viewer.