Skip to content

Commit d67cfec

Browse files
committed
update test
1 parent 982667e commit d67cfec

File tree

5 files changed

+72
-237
lines changed

5 files changed

+72
-237
lines changed

test/layers/sanitizer/CMakeLists.txt

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
# See LICENSE.TXT
44
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

6-
set(UR_VALIDATION_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR})
7-
set(VAL_TEST_PREFIX validation_test)
6+
set(UR_SANITIZER_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR})
7+
set(SAN_TEST_PREFIX sanitizer_test)
88

9-
function(add_validation_test_executable name)
10-
add_ur_executable(${VAL_TEST_PREFIX}-${name}
9+
function(add_sanitizer_test_executable name)
10+
add_ur_executable(${SAN_TEST_PREFIX}-${name}
1111
${ARGN})
12-
target_link_libraries(${VAL_TEST_PREFIX}-${name}
12+
target_link_libraries(${SAN_TEST_PREFIX}-${name}
1313
PRIVATE
1414
${PROJECT_NAME}::loader
1515
${PROJECT_NAME}::headers
@@ -18,39 +18,34 @@ function(add_validation_test_executable name)
1818
GTest::gtest_main)
1919
endfunction()
2020

21-
function(set_validation_test_properties name)
22-
set_tests_properties(${name} PROPERTIES LABELS "validation")
21+
function(set_sanitizer_test_properties name)
22+
set_tests_properties(${name} PROPERTIES LABELS "sanitizer")
2323
set_property(TEST ${name} PROPERTY ENVIRONMENT
24-
"UR_ENABLE_LAYERS=UR_LAYER_FULL_VALIDATION"
25-
"UR_ADAPTERS_FORCE_LOAD=\"$<TARGET_FILE:ur_adapter_mock>\""
26-
"UR_LOG_VALIDATION=level:debug\;flush:debug\;output:stdout")
24+
"UR_LOG_SANITIZER=level:debug\;flush:debug\;output:stdout")
2725
endfunction()
2826

29-
function(add_validation_test name)
30-
add_validation_test_executable(${name} ${ARGN})
27+
function(add_sanitizer_test name)
28+
add_sanitizer_test_executable(${name} ${ARGN})
3129

3230
add_test(NAME ${name}
33-
COMMAND ${VAL_TEST_PREFIX}-${name}
31+
COMMAND ${SAN_TEST_PREFIX}-${name}
3432
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
3533

36-
set_validation_test_properties(${name})
34+
set_sanitizer_test_properties(${name})
3735
endfunction()
3836

39-
function(add_validation_match_test name)
40-
add_validation_test_executable(${name} ${ARGN})
37+
function(add_sanitizer_match_test name)
38+
add_sanitizer_test_executable(${name} ${ARGN})
4139

4240
add_test(NAME ${name}
4341
COMMAND ${CMAKE_COMMAND}
4442
-D MODE=stdout
45-
-D TEST_FILE=$<TARGET_FILE:${VAL_TEST_PREFIX}-${name}>
43+
-D TEST_FILE=$<TARGET_FILE:${SAN_TEST_PREFIX}-${name}>
4644
-D MATCH_FILE=${CMAKE_CURRENT_SOURCE_DIR}/${name}.out.match
4745
-P ${PROJECT_SOURCE_DIR}/cmake/match.cmake
4846
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
4947

50-
set_validation_test_properties(${name})
48+
set_sanitizer_test_properties(${name})
5149
endfunction()
5250

53-
add_validation_test(parameters parameters.cpp)
54-
add_validation_match_test(leaks leaks.out.match leaks.cpp)
55-
add_validation_match_test(leaks_mt leaks_mt.out.match leaks_mt.cpp)
56-
add_validation_match_test(lifetime lifetime.out.match lifetime.cpp)
51+
add_sanitizer_test(asan asan.cpp)

test/layers/sanitizer/asan.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
*
3+
* Copyright (C) 2024 Intel Corporation
4+
*
5+
* Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
6+
* See LICENSE.TXT
7+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8+
*
9+
* @file codeloc.cpp
10+
*
11+
*/
12+
13+
#include <gtest/gtest.h>
14+
#include <ur_api.h>
15+
16+
TEST(DeviceASan, Initialization) {
17+
ur_result_t status;
18+
19+
ur_loader_config_handle_t loaderConfig;
20+
status = urLoaderConfigCreate(&loaderConfig);
21+
ASSERT_EQ(status, UR_RESULT_SUCCESS);
22+
status = urLoaderConfigEnableLayer(loaderConfig, "UR_LAYER_ASAN");
23+
ASSERT_EQ(status, UR_RESULT_SUCCESS);
24+
25+
status = urLoaderInit(0, loaderConfig);
26+
ASSERT_EQ(status, UR_RESULT_SUCCESS);
27+
28+
ur_adapter_handle_t adapter;
29+
status = urAdapterGet(1, &adapter, nullptr);
30+
ASSERT_EQ(status, UR_RESULT_SUCCESS);
31+
32+
ur_platform_handle_t platform;
33+
status = urPlatformGet(&adapter, 1, 1, &platform, nullptr);
34+
ASSERT_EQ(status, UR_RESULT_SUCCESS);
35+
36+
ur_device_handle_t device;
37+
status = urDeviceGet(platform, UR_DEVICE_TYPE_DEFAULT, 1, &device, nullptr);
38+
ASSERT_EQ(status, UR_RESULT_SUCCESS);
39+
40+
ur_context_handle_t context;
41+
status = urContextCreate(1, &device, nullptr, &context);
42+
ASSERT_EQ(status, UR_RESULT_SUCCESS);
43+
44+
status = urDeviceRelease(device);
45+
ASSERT_EQ(status, UR_RESULT_SUCCESS);
46+
47+
status = urAdapterRelease(adapter);
48+
ASSERT_EQ(status, UR_RESULT_SUCCESS);
49+
50+
status = urLoaderTearDown();
51+
ASSERT_EQ(status, UR_RESULT_SUCCESS);
52+
53+
status = urLoaderConfigRelease(loaderConfig);
54+
ASSERT_EQ(status, UR_RESULT_SUCCESS);
55+
}

test/layers/sanitizer/fixtures.hpp

Lines changed: 0 additions & 176 deletions
This file was deleted.

test/layers/sanitizer/lifetime.cpp

Lines changed: 0 additions & 27 deletions
This file was deleted.

test/layers/sanitizer/lifetime.out.match

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)