Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #193 from ldorau/test-fix-run_test_get-and-run_tes…
Browse files Browse the repository at this point in the history
…t_get_put

test: fix run_test_get and run_test_get_put
  • Loading branch information
marcinslusarz authored Mar 29, 2019
2 parents 54caadb + 9ab9185 commit 0e53714
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 7 additions & 4 deletions tests/test-mt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ else()
endif()

if (${TRACER} IN_LIST valgrind)
set(SKIP "skip") # skip tests that last very long under Valgrind
# skip tests that last very long under Valgrind
execute(0 ${TEST_DIR}/vmemcache_test_mt ${TEST_POOL_LOCATION} ${N_THREADS} ${N_OPS} ${SEED} "skip")
else()
set(SKIP "")
endif()
execute(0 ${TEST_DIR}/vmemcache_test_mt ${TEST_POOL_LOCATION} ${N_THREADS} ${N_OPS} ${SEED})

execute(0 ${TEST_DIR}/vmemcache_test_mt ${TEST_POOL_LOCATION} ${N_THREADS} ${N_OPS} ${SEED} ${SKIP})
# additional tests for number of threads == 1 and 2
execute(0 ${TEST_DIR}/vmemcache_test_mt ${TEST_POOL_LOCATION} 1)
execute(0 ${TEST_DIR}/vmemcache_test_mt ${TEST_POOL_LOCATION} 2)
endif()

cleanup()
9 changes: 8 additions & 1 deletion tests/vmemcache_test_mt.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ worker_thread_get(void *arg)
size_t vbufsize = BUF_SIZE; /* size of vbuf */
size_t vsize = 0; /* real size of the object */

for (i = 0; i < ctx->ops_count; i++) {
/* starting from 1, because the entry #0 has been evicted */
for (i = 1; i < ctx->ops_count; i++) {
if (vmemcache_get(ctx->cache, &i, sizeof(i),
vbuf, vbufsize, 0, &vsize) == -1)
UT_FATAL("ERROR: vmemcache_get: %s",
Expand Down Expand Up @@ -285,6 +286,9 @@ run_test_get(VMEMcache *cache, unsigned n_threads, os_thread_t *threads,
printf("%s: PASSED\n", __func__);
}

static void
on_miss_cb(VMEMcache *cache, const void *key, size_t key_size, void *arg);

/*
* run_test_get_put -- (internal) run test for vmemcache_get()
* and vmemcache_put()
Expand All @@ -305,6 +309,8 @@ run_test_get_put(VMEMcache *cache, unsigned n_threads, os_thread_t *threads,
ctx[i].worker = worker_thread_put_in_gets;
}

vmemcache_callback_on_miss(cache, on_miss_cb, ctx);

printf("%s: STARTED\n", __func__);

run_threads(n_threads, threads, ctx);
Expand All @@ -314,6 +320,7 @@ run_test_get_put(VMEMcache *cache, unsigned n_threads, os_thread_t *threads,

/*
* on_miss_cb -- (internal) 'on miss' callback for run_test_get_on_miss
* and run_test_get_put
*/
static void
on_miss_cb(VMEMcache *cache, const void *key, size_t key_size, void *arg)
Expand Down

0 comments on commit 0e53714

Please sign in to comment.