56
56
// the message can still be buffered by stdio. We turn the bufferization
57
57
// off explicitly.
58
58
//
59
+ // 4. We want to check both compilation flow in (1) and the message in (3),
60
+ // but these messages can interleave and fail to match. To avoid this,
61
+ // first run with SYCL_PI_TRACE and collect a trace, and then with
62
+ // SHOULD_CRASH (without SYCL_PI_TRACE) to collect an error message.
63
+ //
59
64
// SYCL_DEVICELIB_INHIBIT_NATIVE=1 environment variable is used to force a mode
60
65
// in SYCL Runtime, so it doesn't look into a device extensions list and always
61
66
// link the fallback library.
70
75
//
71
76
// Overall this sounds stable enough. What could possibly go wrong?
72
77
//
73
- // RUN: env SYCL_PI_TRACE=1 CL_CONFIG_USE_VECTORIZER=False SYCL_DEVICE_TYPE=CPU EXPECTED_SIGNAL=SIGABRT SKIP_IF_NO_EXT=1 %t.out 2>%t.stderr.native >%t.stdout.native
78
+ // RUN: env SYCL_PI_TRACE=1 SHOULD_CRASH=1 CL_CONFIG_USE_VECTORIZER=False SYCL_DEVICE_TYPE=CPU EXPECTED_SIGNAL=SIGABRT SKIP_IF_NO_EXT=1 %t.out 2>%t.stderr.native >%t.stdout.native
74
79
// RUN: FileCheck %s --input-file %t.stdout.native --check-prefixes=CHECK-NATIVE || FileCheck %s --input-file %t.stderr.native --check-prefix CHECK-NOTSUPPORTED
75
80
// RUN: FileCheck %s --input-file %t.stderr.native --check-prefixes=CHECK-MESSAGE || FileCheck %s --input-file %t.stderr.native --check-prefix CHECK-NOTSUPPORTED
76
81
//
77
- // RUN: env SYCL_PI_TRACE=1 SYCL_DEVICELIB_INHIBIT_NATIVE=cl_intel_devicelib_assert CL_CONFIG_USE_VECTORIZER=False SYCL_DEVICE_TYPE=CPU EXPECTED_SIGNAL=SIGSEGV %t.out 2>%t.stderr.fallback >%t.stdout.fallback
78
- // RUN: FileCheck %s --input-file %t.stdout.fallback --check-prefixes=CHECK-FALLBACK,CHECK-MESSAGE
82
+ // RUN: env SYCL_PI_TRACE=1 SYCL_DEVICELIB_INHIBIT_NATIVE=cl_intel_devicelib_assert CL_CONFIG_USE_VECTORIZER=False SYCL_DEVICE_TYPE=CPU EXPECTED_SIGNAL=SIGSEGV %t.out >%t.stdout.pi.fallback
83
+ // RUN: env SHOULD_CRASH=1 SYCL_DEVICELIB_INHIBIT_NATIVE=cl_intel_devicelib_assert CL_CONFIG_USE_VECTORIZER=False SYCL_DEVICE_TYPE=CPU EXPECTED_SIGNAL=SIGSEGV %t.out >%t.stdout.msg.fallback
84
+ // RUN: FileCheck %s --input-file %t.stdout.pi.fallback --check-prefixes=CHECK-FALLBACK
85
+ // RUN: FileCheck %s --input-file %t.stdout.msg.fallback --check-prefixes=CHECK-MESSAGE
79
86
//
80
87
// CHECK-NATIVE: ---> piProgramBuild
81
88
// CHECK-FALLBACK: ---> piProgramLink
@@ -134,6 +141,8 @@ void simple_vadd(const std::array<T, N> &VA, const std::array<T, N> &VB,
134
141
exit (EXIT_SKIP_TEST);
135
142
}
136
143
144
+ int shouldCrash = getenv (" SHOULD_CRASH" ) ? 1 : 0 ;
145
+
137
146
cl::sycl::range<1 > numOfItems{N};
138
147
cl::sycl::buffer<T, 1 > bufferA (VA.data (), numOfItems);
139
148
cl::sycl::buffer<T, 1 > bufferB (VB.data (), numOfItems);
@@ -146,7 +155,9 @@ void simple_vadd(const std::array<T, N> &VA, const std::array<T, N> &VB,
146
155
147
156
cgh.parallel_for <class SimpleVaddT >(numOfItems, [=](cl::sycl::id<1 > wiID) {
148
157
accessorC[wiID] = accessorA[wiID] + accessorB[wiID];
149
- assert (accessorC[wiID] == 0 && " Invalid value" );
158
+ if (shouldCrash) {
159
+ assert (accessorC[wiID] == 0 && " Invalid value" );
160
+ }
150
161
});
151
162
});
152
163
deviceQueue.wait_and_throw ();
@@ -160,9 +171,19 @@ int main() {
160
171
if (WIFEXITED (status) && WEXITSTATUS (status) == EXIT_SKIP_TEST) {
161
172
return 0 ;
162
173
}
163
- if (!WIFSIGNALED (status)) {
164
- fprintf (stderr, " error: process did not terminate by a signal\n " );
165
- return 1 ;
174
+ if (getenv (" SHOULD_CRASH" )) {
175
+ if (!WIFSIGNALED (status)) {
176
+ fprintf (stderr, " error: process did not terminate by a signal\n " );
177
+ return 1 ;
178
+ }
179
+ } else {
180
+ if (WIFSIGNALED (status)) {
181
+ fprintf (stderr, " error: process should not terminate\n " );
182
+ return 1 ;
183
+ }
184
+ // We should not check anything if the child finished successful and this
185
+ // was expected.
186
+ return 0 ;
166
187
}
167
188
int sig = WTERMSIG (status);
168
189
int expected = 0 ;
0 commit comments