Skip to content

Commit 65e2d81

Browse files
committed
Fixed TestCLI unit tests on linux.
1 parent 20b92ed commit 65e2d81

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

test/bin2cpp_unittest/TestCLI.cpp

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ using namespace TestCLIUtils;
131131

132132
void TestCLI::SetUp()
133133
{
134-
135134
}
136135

137136
void TestCLI::TearDown()
@@ -752,6 +751,9 @@ TEST_F(TestCLI, testErrorMissingArgumentFileOrDir)
752751

753752
//run the command
754753
int returnCode = system(cmdline.c_str());
754+
#ifdef __linux__
755+
returnCode = WEXITSTATUS(returnCode);
756+
#endif
755757
ASSERT_EQ(APP_ERROR_MISSINGARGUMENTS, returnCode) << "The command line '" << cmdline.c_str() << "' returned " << returnCode;
756758

757759
//load output file
@@ -796,6 +798,9 @@ TEST_F(TestCLI, testErrorMissingArgumentOutput)
796798

797799
//run the command
798800
int returnCode = system(cmdline.c_str());
801+
#ifdef __linux__
802+
returnCode = WEXITSTATUS(returnCode);
803+
#endif
799804
ASSERT_EQ(APP_ERROR_MISSINGARGUMENTS, returnCode) << "The command line '" << cmdline.c_str() << "' returned " << returnCode;
800805

801806
//load output file
@@ -840,6 +845,9 @@ TEST_F(TestCLI, testErrorMissingArgumentHeaderfile)
840845

841846
//run the command
842847
int returnCode = system(cmdline.c_str());
848+
#ifdef __linux__
849+
returnCode = WEXITSTATUS(returnCode);
850+
#endif
843851
ASSERT_EQ(APP_ERROR_MISSINGARGUMENTS, returnCode) << "The command line '" << cmdline.c_str() << "' returned " << returnCode;
844852

845853
//load output file
@@ -884,6 +892,9 @@ TEST_F(TestCLI, testErrorMissingArgumentIdentifier)
884892

885893
//run the command
886894
int returnCode = system(cmdline.c_str());
895+
#ifdef __linux__
896+
returnCode = WEXITSTATUS(returnCode);
897+
#endif
887898
ASSERT_EQ(APP_ERROR_MISSINGARGUMENTS, returnCode) << "The command line '" << cmdline.c_str() << "' returned " << returnCode;
888899

889900
//load output file
@@ -929,6 +940,9 @@ TEST_F(TestCLI, testErrorMissingArgumentEncoding)
929940

930941
//run the command
931942
int returnCode = system(cmdline.c_str());
943+
#ifdef __linux__
944+
returnCode = WEXITSTATUS(returnCode);
945+
#endif
932946
ASSERT_EQ(APP_ERROR_MISSINGARGUMENTS, returnCode) << "The command line '" << cmdline.c_str() << "' returned " << returnCode;
933947

934948
//load output file
@@ -974,6 +988,9 @@ TEST_F(TestCLI, testErrorMissingArgumentGenerator)
974988

975989
//run the command
976990
int returnCode = system(cmdline.c_str());
991+
#ifdef __linux__
992+
returnCode = WEXITSTATUS(returnCode);
993+
#endif
977994
ASSERT_EQ(APP_ERROR_MISSINGARGUMENTS, returnCode) << "The command line '" << cmdline.c_str() << "' returned " << returnCode;
978995

979996
//load output file
@@ -1019,6 +1036,9 @@ TEST_F(TestCLI, testErrorInputFileNotFound)
10191036

10201037
//run the command
10211038
int returnCode = system(cmdline.c_str());
1039+
#ifdef __linux__
1040+
returnCode = WEXITSTATUS(returnCode);
1041+
#endif
10221042
ASSERT_EQ(APP_ERROR_INPUTFILENOTFOUND, returnCode) << "The command line '" << cmdline.c_str() << "' returned " << returnCode;
10231043

10241044
//load output file
@@ -1048,7 +1068,11 @@ TEST_F(TestCLI, testErrorOutputFile)
10481068
cmdline.append(" --file=");
10491069
cmdline.append(getBin2cppPath()); //itself
10501070
cmdline.append(" --output=generated_files");
1071+
#ifdef _WIN32
10511072
cmdline.append(" --headerfile=:?.h");
1073+
#else
1074+
cmdline.append(" --headerfile=.");
1075+
#endif
10521076
//cmdline.append(headerFileName);
10531077
cmdline.append(" --identifier=");
10541078
cmdline.append(ra::gtesthelp::getTestCaseName().c_str());
@@ -1063,6 +1087,9 @@ TEST_F(TestCLI, testErrorOutputFile)
10631087

10641088
//run the command
10651089
int returnCode = system(cmdline.c_str());
1090+
#ifdef __linux__
1091+
returnCode = WEXITSTATUS(returnCode);
1092+
#endif
10661093
ASSERT_EQ(APP_ERROR_UNABLETOCREATEOUTPUTFILES, returnCode) << "The command line '" << cmdline.c_str() << "' returned " << returnCode;
10671094

10681095
//load output file
@@ -1108,6 +1135,9 @@ TEST_F(TestCLI, testErrorTooManyArgumentsFileAndDir)
11081135

11091136
//run the command
11101137
int returnCode = system(cmdline.c_str());
1138+
#ifdef __linux__
1139+
returnCode = WEXITSTATUS(returnCode);
1140+
#endif
11111141
ASSERT_EQ(APP_ERROR_TOOMANYARGUMENTS, returnCode) << "The command line '" << cmdline.c_str() << "' returned " << returnCode;
11121142

11131143
//load output file
@@ -1153,6 +1183,9 @@ TEST_F(TestCLI, testErrorTooManyArgumentsHeaderfile)
11531183

11541184
//run the command
11551185
int returnCode = system(cmdline.c_str());
1186+
#ifdef __linux__
1187+
returnCode = WEXITSTATUS(returnCode);
1188+
#endif
11561189
ASSERT_EQ(APP_ERROR_TOOMANYARGUMENTS, returnCode) << "The command line '" << cmdline.c_str() << "' returned " << returnCode;
11571190

11581191
//load output file
@@ -1198,6 +1231,9 @@ TEST_F(TestCLI, testErrorTooManyArgumentsIdentifier)
11981231

11991232
//run the command
12001233
int returnCode = system(cmdline.c_str());
1234+
#ifdef __linux__
1235+
returnCode = WEXITSTATUS(returnCode);
1236+
#endif
12011237
ASSERT_EQ(APP_ERROR_TOOMANYARGUMENTS, returnCode) << "The command line '" << cmdline.c_str() << "' returned " << returnCode;
12021238

12031239
//load output file
@@ -1243,6 +1279,9 @@ TEST_F(TestCLI, testErrorInputDirNotFound)
12431279

12441280
//run the command
12451281
int returnCode = system(cmdline.c_str());
1282+
#ifdef __linux__
1283+
returnCode = WEXITSTATUS(returnCode);
1284+
#endif
12461285
ASSERT_EQ(APP_ERROR_INPUTDIRNOTFOUND, returnCode) << "The command line '" << cmdline.c_str() << "' returned " << returnCode;
12471286

12481287
//load output file

0 commit comments

Comments
 (0)