From 4e02041bb14d92d8e724bd81430f8f48658c37ca Mon Sep 17 00:00:00 2001 From: KunoiSayami Date: Mon, 13 Dec 2021 21:53:55 +0800 Subject: test(skiplist): Add more test Signed-off-by: KunoiSayami --- db/skiplist_test.cu | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'db/skiplist_test.cu') diff --git a/db/skiplist_test.cu b/db/skiplist_test.cu index 2b42b48..0022c84 100644 --- a/db/skiplist_test.cu +++ b/db/skiplist_test.cu @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. + #include "db/skiplist.cuh" //#include #include #include "leveldb/env.h" +#include "cassert" #include "port/port.h" #include "port/thread_annotations.h" @@ -387,10 +389,10 @@ __host__ void host_insert_test() { init<<>>(&pArena, &skipList); cudaDeviceSynchronize(); - insert_skiplist<<>>(skipList, device_rnd); + //insert_skiplist<<>>(skipList, device_rnd); - cudaDeviceSynchronize(); + //cudaDeviceSynchronize(); insert_and_lookup<<>>(skipList); cudaDeviceSynchronize(); @@ -402,6 +404,34 @@ TEST(SkipTest, TestCudaInsert) { host_insert_test(); } +#define cudaAssert(condition) \ + if (!(condition)){ printf("Assertion %s failed!\n", #condition); asm("trap;"); } + +__global__ void test_empty() { + Arena arena; + Comparator cmp; + SkipList list(cmp, &arena); + assert(!list.Contains(10)); + SkipList::Iterator iter(&list); + assert(!iter.Valid()); + iter.SeekToFirst(); + assert(!iter.Valid()); + iter.Seek(100); + assert(!iter.Valid()); + iter.SeekToLast(); + assert(!iter.Valid()); +} + +__global__ void test_fail() { + std::printf("show some message"); + assert(0); +} + +TEST(SkipTest, Empty) { + test_fail<<<1,1>>>(); + cudaDeviceSynchronize(); +} + /* // Needed when building in C++11 mode. constexpr uint32_t ConcurrentTest::K; -- cgit v1.3.1