77
88#include " offline_compiler_tests.h"
99
10- #include " shared/offline_compiler/source/ocloc_api.h"
1110#include " shared/source/compiler_interface/intermediate_representations.h"
1211#include " shared/source/compiler_interface/oclc_extensions.h"
1312#include " shared/source/debug_settings/debug_settings_manager.h"
@@ -122,7 +121,6 @@ TEST_F(MultiCommandTests, GivenOutputFileWhenBuildingMultiCommandThenSuccessIsRe
122121 };
123122
124123 std::vector<std::string> singleArgs = {
125- " -gen_file" ,
126124 " -file" ,
127125 " test_files/copybuffer.cl" ,
128126 " -device" ,
@@ -156,7 +154,6 @@ TEST_F(MultiCommandTests, GivenSpecifiedOutputDirWhenBuildingMultiCommandThenSuc
156154 };
157155
158156 std::vector<std::string> singleArgs = {
159- " -gen_file" ,
160157 " -file" ,
161158 " test_files/copybuffer.cl" ,
162159 " -device" ,
@@ -200,7 +197,6 @@ TEST_F(MultiCommandTests, GivenSpecifiedOutputDirWithProductConfigValueWhenBuild
200197 };
201198
202199 std::vector<std::string> singleArgs = {
203- " -gen_file" ,
204200 " -file" ,
205201 " test_files/copybuffer.cl" ,
206202 " -device" ,
@@ -284,7 +280,6 @@ TEST_F(MultiCommandTests, GivenOutputFileListFlagWhenBuildingMultiCommandThenSuc
284280 };
285281
286282 std::vector<std::string> singleArgs = {
287- " -gen_file" ,
288283 " -file" ,
289284 " test_files/copybuffer.cl" ,
290285 " -device" ,
@@ -684,8 +679,7 @@ TEST_F(OfflineCompilerTests, GivenArgsWhenBuildingThenBuildSucceeds) {
684679 " -file" ,
685680 " test_files/copybuffer.cl" ,
686681 " -device" ,
687- gEnvironment ->devicePrefix .c_str (),
688- " -gen_file" };
682+ gEnvironment ->devicePrefix .c_str ()};
689683
690684 pOfflineCompiler = OfflineCompiler::create (argv.size (), argv, true , retVal, oclocArgHelperWithoutInput.get ());
691685
@@ -719,30 +713,25 @@ TEST_F(OfflineCompilerTests, GivenArgsWhenBuildingWithDeviceConfigValueThenBuild
719713 " -file" ,
720714 " test_files/copybuffer.cl" ,
721715 " -device" ,
722- configString,
723- " -gen_file" };
716+ configString};
724717
725- MockOfflineCompiler offlineCompiler{};
726-
727- offlineCompiler.argHelper = oclocArgHelperWithoutInput.get ();
728- retVal = offlineCompiler.initialize (argv.size (), argv);
718+ pOfflineCompiler = OfflineCompiler::create (argv.size (), argv, true , retVal, oclocArgHelperWithoutInput.get ());
729719
720+ EXPECT_NE (nullptr , pOfflineCompiler);
730721 EXPECT_EQ (CL_SUCCESS, retVal);
731722
732723 testing::internal::CaptureStdout ();
733- retVal = offlineCompiler. build ();
724+ retVal = pOfflineCompiler-> build ();
734725 std::string output = testing::internal::GetCapturedStdout ();
735726 EXPECT_EQ (CL_SUCCESS, retVal);
736-
737- Environment testedEnv{configString, offlineCompiler.familyNameWithType };
738- VariableBackup<Environment *> backup (&gEnvironment , &testedEnv);
739-
740727 EXPECT_TRUE (compilerOutputExists (" copybuffer" , " bc" ) || compilerOutputExists (" copybuffer" , " spv" ));
741728 EXPECT_TRUE (compilerOutputExists (" copybuffer" , " gen" ));
742729 EXPECT_TRUE (compilerOutputExists (" copybuffer" , " bin" ));
743730
744- std::string buildLog = offlineCompiler. getBuildLog ();
731+ std::string buildLog = pOfflineCompiler-> getBuildLog ();
745732 EXPECT_STREQ (buildLog.c_str (), " " );
733+
734+ delete pOfflineCompiler;
746735}
747736
748737TEST_F (OfflineCompilerTests, GivenLlvmTextWhenBuildingThenBuildSucceeds) {
@@ -752,8 +741,7 @@ TEST_F(OfflineCompilerTests, GivenLlvmTextWhenBuildingThenBuildSucceeds) {
752741 " test_files/copybuffer.cl" ,
753742 " -device" ,
754743 gEnvironment ->devicePrefix .c_str (),
755- " -llvm_text" ,
756- " -gen_file" };
744+ " -llvm_text" };
757745
758746 pOfflineCompiler = OfflineCompiler::create (argv.size (), argv, true , retVal, oclocArgHelperWithoutInput.get ());
759747
@@ -769,97 +757,6 @@ TEST_F(OfflineCompilerTests, GivenLlvmTextWhenBuildingThenBuildSucceeds) {
769757 delete pOfflineCompiler;
770758}
771759
772- TEST_F (OfflineCompilerTests, WhenGenFileFlagIsNotProvidedThenGenFileIsNotCreated) {
773- uint32_t numOutputs = 0u ;
774- uint64_t *lenOutputs = nullptr ;
775- uint8_t **dataOutputs = nullptr ;
776- char **nameOutputs = nullptr ;
777-
778- bool isSpvFile = false ;
779- bool isGenFile = false ;
780- bool isBinFile = false ;
781-
782- const char *argv[] = {
783- " ocloc" ,
784- " -q" ,
785- " -file" ,
786- " test_files/copybuffer.cl" ,
787- " -device" ,
788- gEnvironment ->devicePrefix .c_str ()};
789-
790- unsigned int argc = sizeof (argv) / sizeof (const char *);
791- int retVal = oclocInvoke (argc, argv,
792- 0 , nullptr , nullptr , nullptr ,
793- 0 , nullptr , nullptr , nullptr ,
794- &numOutputs, &dataOutputs, &lenOutputs, &nameOutputs);
795-
796- EXPECT_EQ (retVal, CL_SUCCESS);
797- EXPECT_EQ (numOutputs, 3u );
798-
799- for (unsigned int i = 0 ; i < numOutputs; i++) {
800- std::string nameOutput (nameOutputs[i]);
801- if (nameOutput.find (" .spv" ) != std::string::npos) {
802- isSpvFile = true ;
803- }
804- if (nameOutput.find (" .gen" ) != std::string::npos) {
805- isGenFile = true ;
806- }
807- if (nameOutput.find (" .bin" ) != std::string::npos) {
808- isBinFile = true ;
809- }
810- }
811-
812- EXPECT_TRUE (isSpvFile);
813- EXPECT_FALSE (isGenFile);
814- EXPECT_TRUE (isBinFile);
815- }
816-
817- TEST_F (OfflineCompilerTests, WhenGenFileFlagIsProvidedThenGenFileIsCreated) {
818- uint32_t numOutputs = 0u ;
819- uint64_t *lenOutputs = nullptr ;
820- uint8_t **dataOutputs = nullptr ;
821- char **nameOutputs = nullptr ;
822-
823- bool isSpvFile = false ;
824- bool isGenFile = false ;
825- bool isBinFile = false ;
826-
827- const char *argv[] = {
828- " ocloc" ,
829- " -q" ,
830- " -gen_file" ,
831- " -file" ,
832- " test_files/copybuffer.cl" ,
833- " -device" ,
834- gEnvironment ->devicePrefix .c_str ()};
835-
836- unsigned int argc = sizeof (argv) / sizeof (const char *);
837- int retVal = oclocInvoke (argc, argv,
838- 0 , nullptr , nullptr , nullptr ,
839- 0 , nullptr , nullptr , nullptr ,
840- &numOutputs, &dataOutputs, &lenOutputs, &nameOutputs);
841-
842- EXPECT_EQ (retVal, CL_SUCCESS);
843- EXPECT_EQ (numOutputs, 4u );
844-
845- for (unsigned int i = 0 ; i < numOutputs; i++) {
846- std::string nameOutput (nameOutputs[i]);
847- if (nameOutput.find (" .spv" ) != std::string::npos) {
848- isSpvFile = true ;
849- }
850- if (nameOutput.find (" .gen" ) != std::string::npos) {
851- isGenFile = true ;
852- }
853- if (nameOutput.find (" .bin" ) != std::string::npos) {
854- isBinFile = true ;
855- }
856- }
857-
858- EXPECT_TRUE (isSpvFile);
859- EXPECT_TRUE (isGenFile);
860- EXPECT_TRUE (isBinFile);
861- }
862-
863760TEST_F (OfflineCompilerTests, WhenFclNotNeededThenDontLoadIt) {
864761 std::vector<std::string> argv = {
865762 " ocloc" ,
@@ -927,8 +824,7 @@ TEST_F(OfflineCompilerTests, GivenCppFileWhenBuildingThenBuildSucceeds) {
927824 " test_files/copybuffer.cl" ,
928825 " -device" ,
929826 gEnvironment ->devicePrefix .c_str (),
930- " -cpp_file" ,
931- " -gen_file" };
827+ " -cpp_file" };
932828
933829 pOfflineCompiler = OfflineCompiler::create (argv.size (), argv, true , retVal, oclocArgHelperWithoutInput.get ());
934830
@@ -951,7 +847,6 @@ TEST_F(OfflineCompilerTests, GivenOutputDirWhenBuildingThenBuildSucceeds) {
951847 " test_files/copybuffer.cl" ,
952848 " -device" ,
953849 gEnvironment ->devicePrefix .c_str (),
954- " -gen_file" ,
955850 " -out_dir" ,
956851 " offline_compiler_test" };
957852
@@ -1294,8 +1189,7 @@ TEST(OfflineCompilerTest, givenSpvOnlyOptionPassedWhenCmdLineParsedThenGenerateO
12941189 " myOutputFileName" ,
12951190 " -spv_only" ,
12961191 " -device" ,
1297- gEnvironment ->devicePrefix .c_str (),
1298- " -gen_file" };
1192+ gEnvironment ->devicePrefix .c_str ()};
12991193
13001194 auto mockOfflineCompiler = std::unique_ptr<MockOfflineCompiler>(new MockOfflineCompiler ());
13011195 ASSERT_NE (nullptr , mockOfflineCompiler);
@@ -1504,8 +1398,7 @@ TEST(OfflineCompilerTest, givenOutputFileOptionWhenSourceIsCompiledThenOutputFil
15041398 " -output" ,
15051399 " myOutputFileName" ,
15061400 " -device" ,
1507- gEnvironment ->devicePrefix .c_str (),
1508- " -gen_file" };
1401+ gEnvironment ->devicePrefix .c_str ()};
15091402
15101403 auto mockOfflineCompiler = std::unique_ptr<MockOfflineCompiler>(new MockOfflineCompiler ());
15111404 ASSERT_NE (nullptr , mockOfflineCompiler);
@@ -1538,8 +1431,7 @@ TEST(OfflineCompilerTest, givenDebugDataAvailableWhenSourceIsBuiltThenDebugDataF
15381431 " -output" ,
15391432 " myOutputFileName" ,
15401433 " -device" ,
1541- gEnvironment ->devicePrefix .c_str (),
1542- " -gen_file" };
1434+ gEnvironment ->devicePrefix .c_str ()};
15431435
15441436 char debugData[10 ];
15451437 MockCompilerDebugVars igcDebugVars (gEnvironment ->igcDebugVars );
@@ -2140,8 +2032,7 @@ TEST(OclocCompile, givenSpirvInputThenDontGenerateSpirvFile) {
21402032 " offline_compiler_test" ,
21412033 " -device" ,
21422034 gEnvironment ->devicePrefix .c_str (),
2143- " -spirv_input" ,
2144- " -gen_file" };
2035+ " -spirv_input" };
21452036
21462037 int retVal = ocloc.initialize (argv.size (), argv);
21472038 ASSERT_EQ (0 , retVal);
0 commit comments