Project

General

Profile

Black-box tester

To better test your chidb implementation, we are providing a black-box testing program. This program will take a libchidb implementation, a run a series of tests on it. However, you are not provided with the source code for the tests, or even a description of what each test does (other than what part of libchidb it is testing). If a test does not pass, you will have to rely on the testing framework's error message, which could be something useful like this:

CU_ASSERT(db->bt->pager->page_size == 1024);

Or something less useful like this:

CU_ASSERT(!strcmp(data, values[i]));

Or you might just encounter a segmentation fault. If you don't immediately know why the test failed, then it's time to fire up the debugger and figure it out.

How to run the black-box tester

  1. Download the following tarball: chidb-blackbox.tar.gz (for 32-bit machines) or chidb-blackbox_64bit.tar.gz (for 64-bit machines)
  2. Untar it in an empty directory.
  3. Set the LD_LIBRARY_PATH environment variable to wherever your libchidb.so file is.
  4. Run the executable "tests".

Comments

  1. The tests for Step N assume that Step N-1 has been implemented. However, don't feel like you have to nail all the tests in one step before moving on to the next one. The tests exploit several corner cases, so maybe you just haven't figured those out yet, but have a good enough solution to move on to the next step.
  2. Do not obsess about the tests. They are not going to be used to grade you, and are simply provided as a way for you to quickly verify if your solution for a given step is correct.
  3. If your implementation passes all the tests, that doesn't mean that your project is 100% correct, but it's certainly a pretty good sign.

Expected output

If all the tests run successfully, you should see the following:


     CUnit - A Unit testing framework for C - Version 2.1-0
     http://cunit.sourceforge.net/

Suite: utils
  Test: Get/put uint16 ... passed
  Test: Get/put uint32 ... passed
  Test: Get/put varint32 ... passed
Suite: dbrecord
  Test: Single-string record ... passed
  Test: Single-int8 record ... passed
  Test: Single-int16 record ... passed
  Test: Single-int32 record ... passed
  Test: Single-null record ... passed
  Test: Multiple-field record ... passed
  Test: Packing/unpacking a record ... passed
Suite: pager
  Test: Opening an existing file ... passed
  Test: Reading pages ... passed
  Test: Allocating/writing/reading a page ... passed
Suite: Step 1a: Opening an existing chidb file
  Test: 1a.1 ... passed
  Test: 1a.2 ... passed
  Test: 1a.3 ... passed
Suite: Step 2: Loading a B-Tree node from the file
  Test: 2.1 ... passed
  Test: 2.2 ... passed
  Test: 2.3 ... passed
  Test: 2.4 ... passed
  Test: 2.5 ... passed
  Test: 2.6 ... passed
Suite: Step 3: Creating and writing a B-Tree node to disk
  Test: 3.1 ... passed
  Test: 3.2 ... passed
  Test: 3.3 ... passed
  Test: 3.4 ... passed
  Test: 3.5 ... passed
  Test: 3.6 ... passed
  Test: 3.7 ... passed
  Test: 3.8 ... passed
  Test: 3.9 ... passed
  Test: 3.10 ... passed
Suite: Step 1b: Opening a new chidb file
  Test: 1b.1 ... passed
  Test: 1b.2 ... passed
Suite: Step 4: Manipulating B-Tree cells
  Test: 4.1 ... passed
  Test: 4.2 ... passed
  Test: 4.3 ... passed
  Test: 4.4 ... passed
Suite: Step 5: Finding a value in a B-Tree
  Test: 5.1 ... passed
  Test: 5.2 ... passed
Suite: Step 6: Insertion into a leaf without splitting
  Test: 6.1 ... passed
  Test: 6.2 ... passed
Suite: Step 7: Insertion with splitting
  Test: 7.1 ... passed
  Test: 7.2 ... passed
  Test: 7.3 ... passed
Suite: Step 8: Supporting index B-Trees
  Test: 8.1 ... passed
  Test: 8.2 ... passed
  Test: 8.3 ... passed

--Run Summary: Type      Total     Ran  Passed  Failed
               suites       12      12     n/a       0
               tests        48      48      48       0
               asserts   56611   56611   56611       0