Skip to content

Commit

Permalink
txlib: Add test cases for transactional multisets
Browse files Browse the repository at this point in the history
  • Loading branch information
tdz committed Nov 23, 2017
1 parent 990bf31 commit b9d470b
Show file tree
Hide file tree
Showing 6 changed files with 1,023 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/txlib/tests/pubapi/Makefile.am
Expand Up @@ -18,6 +18,8 @@

TESTS = txlist-pubapi-t1.test \
txlist-pubapi-t4.test \
txmultiset-pubapi-t1.test \
txmultiset-pubapi-t4.test \
txqueue-pubapi-t1.test \
txqueue-pubapi-t4.test \
txstack-pubapi-t1.test \
Expand All @@ -29,13 +31,18 @@ TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/build-aux/tap-driver.sh

check_PROGRAMS = txlist-pubapi.test \
txmultiset-pubapi.test \
txqueue-pubapi.test \
txstack-pubapi.test

txlist_pubapi_test_SOURCES = txlist_pubapi.c \
txlist_test.c \
txlist_test.h

txmultiset_pubapi_test_SOURCES = txmultiset_pubapi.c \
txmultiset_test.c \
txmultiset_test.h

txqueue_pubapi_test_SOURCES = txqueue_pubapi.c \
txqueue_test.c \
txqueue_test.h
Expand Down
23 changes: 23 additions & 0 deletions modules/txlib/tests/pubapi/txmultiset-pubapi-t1.test
@@ -0,0 +1,23 @@
#!/bin/sh

# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

./txmultiset-pubapi.test -t1

echo $?
23 changes: 23 additions & 0 deletions modules/txlib/tests/pubapi/txmultiset-pubapi-t4.test
@@ -0,0 +1,23 @@
#!/bin/sh

# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

./txmultiset-pubapi.test -t4

echo $?
71 changes: 71 additions & 0 deletions modules/txlib/tests/pubapi/txmultiset_pubapi.c
@@ -0,0 +1,71 @@
/* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "opts.h"
#include "tap.h"
#include "taputils.h"
#include "txmultiset_test.h"

int
main(int argc, char **argv)
{
switch (parse_opts(argc, argv, PARSE_OPTS_STRING())) {
case PARSE_OPTS_EXIT:
return EXIT_SUCCESS;
case PARSE_OPTS_ERROR:
return EXIT_FAILURE;
default:
break;
}

if (number_of_txmultiset_tests() <= g_off) {
fprintf(stderr, "Test index out of range\n");
return EXIT_FAILURE;
}

size_t off = g_off;
size_t num;

if (!g_num) {
num = number_of_txmultiset_tests() - off;
} else {
num = g_num;
}

if (number_of_txmultiset_tests() < (off + g_num)) {
fprintf(stderr, "Test index out of range\n");
return EXIT_FAILURE;
}

/* run tests */

tap_version(12);

const struct test_func* test_beg = txmultiset_test + off;
const struct test_func* test_end = txmultiset_test + off + num;

run_tests(test_beg, test_end, g_nthreads, g_loop, g_btype, g_cycles);

return EXIT_SUCCESS;
}

0 comments on commit b9d470b

Please sign in to comment.