Skip to content

Commit

Permalink
Fix building media sharing tests (#389)
Browse files Browse the repository at this point in the history
* Add media_sharing to cmakes

* Adjust cases to ADD_TEST macro

* Review fixes
  • Loading branch information
gwawiork authored and kpet committed Jul 29, 2019
1 parent 1d2e0ca commit bcf994c
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 34 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -214,3 +214,4 @@ if(MSVC)
endif(MSVC)

set_property(TARGET COPY_FILES${CONFORMANCE_SUFFIX} PROPERTY FOLDER "CONFORMANCE${CONFORMANCE_SUFFIX}")
add_subdirectory( "test_extensions" )
1 change: 1 addition & 0 deletions test_extensions/CMakeLists.txt
@@ -0,0 +1 @@
add_subdirectory( media_sharing )
4 changes: 3 additions & 1 deletion test_extensions/media_sharing/CMakeLists.txt
@@ -1,6 +1,5 @@
if(WIN32)
list(APPEND CLConform_LIBRARIES d3d9.lib dxva2.lib )
endif(WIN32)

set (MEDIA_SOURCES
main.cpp
Expand All @@ -21,6 +20,7 @@ set (MEDIA_SOURCES
../../test_common/harness/mt19937.c
../../test_common/harness/parseParameters.cpp
../../test_common/harness/crc32.c
../../test_common/harness/msvc9.c
)

add_executable(conformance_test_media_surface_sharing
Expand All @@ -32,3 +32,5 @@ set_source_files_properties(

TARGET_LINK_LIBRARIES(conformance_test_media_surface_sharing
${CLConform_LIBRARIES})

endif(WIN32)
48 changes: 15 additions & 33 deletions test_extensions/media_sharing/main.cpp
@@ -1,6 +1,6 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand All @@ -18,38 +18,20 @@

#include "../../test_common/harness/testHarness.h"
#include "utils.h"
#include "procs.h"

extern int test_context_create(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_device_ids(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_api(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_kernel(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_other_data_types(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_memory_access(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_interop_user_sync(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);

basefn basefn_list[] = {
test_context_create,
test_get_device_ids,
test_api,
test_kernel,
test_other_data_types,
test_memory_access,
test_interop_user_sync,
};

const char *basefn_names[] = {
"test_context_create",
"test_get_device_ids",
"test_api",
"test_kernel",
"test_other_data_types",
"test_memory_access",
"test_interop_user_sync",
test_definition test_list[] = {
ADD_TEST( context_create ),
ADD_TEST( get_device_ids ),
ADD_TEST( api ),
ADD_TEST( kernel ),
ADD_TEST( other_data_types ),
ADD_TEST( memory_access ),
ADD_TEST( interop_user_sync )
};

ct_assert((sizeof(basefn_names) / sizeof(basefn_names[0])) == (sizeof(basefn_list) / sizeof(basefn_list[0])));

int num_fns = sizeof(basefn_names) / sizeof(char *);
const int test_num = ARRAY_SIZE(test_list);

clGetDeviceIDsFromDX9MediaAdapterKHR_fn clGetDeviceIDsFromDX9MediaAdapterKHR = NULL;
clCreateFromDX9MediaSurfaceKHR_fn clCreateFromDX9MediaSurfaceKHR = NULL;
Expand Down Expand Up @@ -207,16 +189,16 @@ bool CmdlineParse(int argc, const char *argv[])
int main(int argc, const char *argv[])
{
if (!CmdlineParse(argc, argv))
return 2;
return TEST_FAIL;

if (!DetectPlatformAndDevice())
{
log_info("Test was not run, because the media surface sharing extension is not supported\n");
return TEST_NOT_SUPPORTED;
return TEST_SKIP;
}

if (!MediaSurfaceSharingExtensionInit())
return 2;
return TEST_FAIL;

return runTestHarness( argc, argv, num_fns, basefn_list, basefn_names, false, true, 0 );
return runTestHarness(argc, argv, test_num, test_list, false, true, 0);
}
31 changes: 31 additions & 0 deletions test_extensions/media_sharing/procs.h
@@ -0,0 +1,31 @@
//
// Copyright (c) 2019 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//


#ifndef __MEDIA_SHARING_PROCS_H__
#define __MEDIA_SHARING_PROCS_H__


extern int test_context_create(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_device_ids(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_api(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_kernel(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_other_data_types(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_memory_access(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_interop_user_sync(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);


#endif // #ifndef __MEDIA_SHARING_PROCS_H__

0 comments on commit bcf994c

Please sign in to comment.