summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDenis Steckelmacher <steckdenis@yahoo.fr>2011-06-12 17:18:19 +0200
committerDenis Steckelmacher <steckdenis@yahoo.fr>2011-06-12 17:18:19 +0200
commitfa3c70ae171338d0d2632db945ac8482725455af (patch)
tree9ba4597eca212ef1f37da66c745af76129a09ec1 /tests
parent006528b1b514439f738f373f421e247ae5a19aa6 (diff)
Implement clEnqueueWriteBuffer
Simple implementation with ReadBufferEvent class renamed to RWBufferEvent and doing both actions. Tests added.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_mem.cpp22
-rw-r--r--tests/tests.c6
2 files changed, 24 insertions, 4 deletions
diff --git a/tests/test_mem.cpp b/tests/test_mem.cpp
index 9556f9a..46f0a71 100644
--- a/tests/test_mem.cpp
+++ b/tests/test_mem.cpp
@@ -160,9 +160,9 @@ START_TEST (test_read_write_subbuf)
cl_command_queue queue;
cl_device_id device;
cl_int result;
- char s[] = "Hello, world !";
+ char s[] = "Hello, Denis !";
- cl_buffer_region create_info = { // "Hello, [world] !"
+ cl_buffer_region create_info = { // "Hello, [denis] !"
.origin = 7,
.size = 5
};
@@ -213,18 +213,34 @@ START_TEST (test_read_write_subbuf)
"the host ptr of a subbuffer must point to a subportion of its parent buffer"
);
+ result = clEnqueueWriteBuffer(queue, subbuf, 1, 0, 5, "world", 0, 0, 0);
+ fail_if(
+ result != CL_SUCCESS,
+ "unable to write to the sub buffer"
+ );
+
char data[16];
result = clEnqueueReadBuffer(queue, subbuf, 1, 0, 5, data, 0, 0, 0);
fail_if(
result != CL_SUCCESS,
- "unable to read the buffer"
+ "unable to read the sub buffer"
);
fail_if(
strncmp(data, "world", 5),
"the subbuffer must contain \"world\""
);
+ result = clEnqueueReadBuffer(queue, buf, 1, 0, sizeof(s), data, 0, 0, 0);
+ fail_if(
+ result != CL_SUCCESS,
+ "unable to read the buffer"
+ );
+ fail_if(
+ strncmp(data, "Hello, world !", sizeof(s)),
+ "the buffer must contain \"Hello, world !\""
+ );
+
clReleaseMemObject(subbuf);
clReleaseMemObject(buf);
clReleaseContext(ctx);
diff --git a/tests/tests.c b/tests/tests.c
index 9ae366d..d75d684 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -13,7 +13,7 @@ int main(int argc, char **argv)
Suite *s = NULL;
if (argc < 2) {
- printf("there is not enough arguments");
+ printf("test <test> [nofork]\n");
return EXIT_FAILURE;
}
@@ -35,6 +35,10 @@ int main(int argc, char **argv)
}
SRunner *sr = srunner_create(s);
+
+ if (argc == 3 && !strcmp("nofork", argv[2]))
+ srunner_set_fork_status (sr, CK_NOFORK);
+
srunner_run_all(sr, CK_NORMAL);
n_failed_tests = srunner_ntests_failed(sr);