@@ -300,7 +300,6 @@ class ValidationTest : public ::testing::Test {
300
300
TEST_METHOD (ValidatePrintfNotAllowed)
301
301
302
302
TEST_METHOD (ValidateWithHash)
303
- TEST_METHOD (ValidateWithExternalValidator)
304
303
TEST_METHOD (ValidateVersionNotAllowed)
305
304
TEST_METHOD (ValidatePreviewBypassHash)
306
305
TEST_METHOD (ValidateProgramVersionAgainstDxilModule)
@@ -325,12 +324,12 @@ class ValidationTest : public ::testing::Test {
325
324
TEST_METHOD (PSVContentValidationCS)
326
325
TEST_METHOD (PSVContentValidationMS)
327
326
TEST_METHOD (PSVContentValidationAS)
327
+ TEST_METHOD (UnitTestExtValidationSupport)
328
328
TEST_METHOD (WrongPSVSize)
329
329
TEST_METHOD (WrongPSVSizeOnZeros)
330
330
TEST_METHOD (WrongPSVVersion)
331
331
332
332
dxc::DxcDllSupport m_dllSupport;
333
- DxcDllExtValidationSupport m_dllExtSupport;
334
333
VersionSupportInfo m_ver;
335
334
336
335
void TestCheck (LPCWSTR name) {
@@ -4210,55 +4209,67 @@ TEST_F(ValidationTest, ValidateWithHash) {
4210
4209
VERIFY_ARE_EQUAL (memcmp (Result, pHeader->Hash .Digest , sizeof (Result)), 0 );
4211
4210
}
4212
4211
4213
- TEST_F (ValidationTest, ValidateWithExternalValidator) {
4214
- /*
4215
- // The below part of the test was run on a local machine,
4216
- // but shouldn't be run yet in automated scenarios, since
4217
- // the DXC repo does not yet have a checked-in dxil.dll.
4218
-
4219
- // set the environment variable that stores the path to the extenral
4220
- // dxil.dll
4221
- SetEnvironmentVariableW(L"DXC_DXIL_DLL_PATH",
4222
- L"D:\\hlsl.bin\\Debug\\bin\\dxil.dll");
4212
+ // For now, 3 things are tested:
4213
+ // 1. The environment variable is not set. GetDxilDllPath() is empty and
4214
+ // DxilDllFailedToLoad() returns false
4215
+ // 2. Given a bogus path in the environment variable, GetDxilDllPath()
4216
+ // retrieves the path but fails to load it as a dll, and returns true
4217
+ // for DxilDllFailedToLoad()
4218
+ // 3. CLSID_DxcCompiler, CLSID_DxcLinker, CLSID_DxcValidator
4219
+ // may be created through DxcDllExtValidationSupport.
4220
+ // This is all to simply test that the new class, DxcDllExtValidationSupport,
4221
+ // works as intended.
4222
+
4223
+ TEST_F (ValidationTest, UnitTestExtValidationSupport) {
4224
+ DxcDllExtValidationSupport m_dllExtSupport1;
4225
+ DxcDllExtValidationSupport m_dllExtSupport2;
4226
+
4227
+ // 1. with no env var set, test GetDxilDllPath() and DxilDllFailedToLoad()
4228
+ m_dllExtSupport1.Initialize ();
4229
+ VERIFY_IS_FALSE (m_dllExtSupport1.DxilDllFailedToLoad ());
4230
+ VERIFY_ARE_EQUAL (m_dllExtSupport1.GetDxilDllPath (), " " );
4231
+
4232
+ // 2. Test with a bogus path in the environment variable
4233
+ SetEnvironmentVariableW (L" DXC_DXIL_DLL_PATH" , L" bogus" );
4223
4234
// also update the CRT environment
4224
- _putenv_s("DXC_DXIL_DLL_PATH", "D:\\hlsl.bin\\Debug\\bin\\dxil.dll");
4225
- */
4235
+ _putenv_s (" DXC_DXIL_DLL_PATH" , " bogus" );
4226
4236
4227
- if (!m_dllExtSupport .IsEnabled ()) {
4228
- VERIFY_SUCCEEDED (m_dllExtSupport .Initialize ());
4237
+ if (!m_dllExtSupport2 .IsEnabled ()) {
4238
+ VERIFY_SUCCEEDED (m_dllExtSupport2 .Initialize ());
4229
4239
}
4230
4240
4231
- if (m_ver. SkipDxilVersion ( 1 , ShaderModel:: kHighestReleasedMinor ))
4232
- return ;
4233
- CComPtr<IDxcBlob> pProgram ;
4234
- CompileSource ( " float4 main(float a:A, float b:B) : SV_Target { return 1; } " ,
4235
- " ps_6_0 " , &pProgram );
4241
+ // validate that m_dllExtSupport2 was able to capture the environment
4242
+ // variable's value, and that loading the bogus path was unsuccessful
4243
+ std::string extPath ( " bogus " ) ;
4244
+ VERIFY_ARE_EQUAL (m_dllExtSupport2. GetDxilDllPath (), extPath);
4245
+ VERIFY_IS_TRUE (m_dllExtSupport2. DxilDllFailedToLoad () );
4236
4246
4247
+ // 3. Test production of class IDs CLSID_DxcCompiler, CLSID_DxcLinker,
4248
+ // and CLSID_DxcValidator through DxcDllExtValidationSupport.
4249
+ CComPtr<IDxcCompiler> pCompiler;
4250
+ CComPtr<IDxcLinker> pLinker;
4237
4251
CComPtr<IDxcValidator> pValidator;
4238
4252
CComPtr<IDxcOperationResult> pResult;
4239
- unsigned Flags = 0 ;
4240
- VERIFY_SUCCEEDED (
4241
- m_dllExtSupport.CreateInstance (CLSID_DxcValidator, &pValidator));
4242
- // With hash.
4243
- VERIFY_SUCCEEDED (pValidator->Validate (pProgram, Flags, &pResult));
4244
- // Make sure the validation was successful.
4245
- HRESULT status;
4246
- VERIFY_IS_NOT_NULL (pResult);
4247
- CComPtr<IDxcBlob> pValidationOutput;
4248
- pResult->GetStatus (&status);
4249
- VERIFY_SUCCEEDED (status);
4250
- pResult->GetResult (&pValidationOutput);
4251
-
4252
- /*
4253
- // as described above, this should only be tested in local scenarios,
4254
- // until dxil.dll is checked into the dxc repo
4255
4253
4256
- // validate that m_dllExtSupport was able to capture the environment
4257
- // variable's value, and that loading the external validator was successful
4258
- VERIFY_IS_TRUE(!m_dllExtSupport.DxilDllFailedToLoad());
4259
- std::string extPath("D:\\hlsl.bin\\Debug\\bin\\dxil.dll");
4260
- VERIFY_ARE_EQUAL(m_dllExtSupport.GetDxilDllPath(), extPath);
4261
- */
4254
+ VERIFY_SUCCEEDED (m_dllExtSupport2.CreateInstance (
4255
+ CLSID_DxcCompiler, __uuidof (IDxcCompiler), (IUnknown **)&pCompiler));
4256
+ VERIFY_SUCCEEDED (m_dllExtSupport2.CreateInstance (
4257
+ CLSID_DxcLinker, __uuidof (IDxcLinker), (IUnknown **)&pLinker));
4258
+ VERIFY_SUCCEEDED (m_dllExtSupport2.CreateInstance (
4259
+ CLSID_DxcValidator, __uuidof (IDxcValidator), (IUnknown **)&pValidator));
4260
+ CComPtr<IMalloc> pMalloc;
4261
+ CComPtr<IDxcCompiler2> pCompiler2;
4262
+ pLinker.Release ();
4263
+ pValidator.Release ();
4264
+ VERIFY_SUCCEEDED (DxcCoGetMalloc (1 , &pMalloc));
4265
+ VERIFY_SUCCEEDED (m_dllExtSupport2.CreateInstance2 (pMalloc, CLSID_DxcCompiler,
4266
+ __uuidof (IDxcCompiler),
4267
+ (IUnknown **)&pCompiler2));
4268
+ VERIFY_SUCCEEDED (m_dllExtSupport2.CreateInstance2 (
4269
+ pMalloc, CLSID_DxcLinker, __uuidof (IDxcLinker), (IUnknown **)&pLinker));
4270
+ VERIFY_SUCCEEDED (m_dllExtSupport2.CreateInstance2 (pMalloc, CLSID_DxcValidator,
4271
+ __uuidof (IDxcValidator),
4272
+ (IUnknown **)&pValidator));
4262
4273
}
4263
4274
4264
4275
TEST_F (ValidationTest, ValidatePreviewBypassHash) {
0 commit comments