Skip to content

Add better tests (probabilistic and math?) #14

Open
@martong

Description

@martong

Create a test framework, where we can synthesize different random thread interleavings and if there is an error, then at least we should be able to display the interleaving which caused the error. (relacy?)
Would be nice to come up with mathematical tests as well. E.g. for copy_update there is a nice test to check that we'd not missed any update:

void test_sum_add() {
    X x{};

    int sum = 0;
    std::thread t2{[&x, &sum]() {
        executeInLoop<1000>([&x, &sum]() {
            sum = x.sum();
        });
    }};

    std::thread t1{[&x]() {
        executeInLoop<1000>([&x]() {
            x.add(3);
        });
    }};

    std::thread t3{[&x]() {
        executeInLoop<1000>([&x]() {
            x.add(4);
        });
    }};

    t1.join();
    t2.join();
    t3.join();
    std::cout << x.sum() << std::endl;
    ASSERT(x.sum() == 7000);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions