Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fib to valgrind #30

Merged
merged 9 commits into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ VALGRIND := $(filter-out valgrind/RaceExampleTest,$(VALGRIND))

# VALGRIND_ALL has currently unavailable tests filtered out
VALGRIND_ALL := $(VALGRIND)
VALGRIND_ALL := $(filter-out valgrind/FibTest,$(VALGRIND_ALL))
VALGRIND_ALL := $(filter-out valgrind/IntervalTreeTest,$(VALGRIND_ALL))
VALGRIND_ALL := $(filter-out valgrind/MatVecTest,$(VALGRIND_ALL))
VALGRIND_ALL := $(filter-out valgrind/PSquareMatrixMultiplyTest,$(VALGRIND_ALL))
Expand All @@ -57,7 +56,7 @@ $(TESTS): test/%: bin/%

$(VALGRIND): valgrind/%: bin/%
# https://stackoverflow.com/a/55130152
valgrind $(VALGRINDFLAGS) ./$^ > /dev/null
valgrind $(VALGRINDFLAGS) ./$^ valgrind > /dev/null
echo valgrind ./$^ Completed

clean:
Expand Down
6 changes: 5 additions & 1 deletion src/FibTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ int test(size_t n, size_t expected) {
}

int main(int argc, char *argv[]) {
int N = 21;
if (argc >= 2)
// Valgrind: reduce test size
N = 13;
size_t prev = 0, cur = 1;
for (int n = 0; n < 21; n++) {
for (int n = 0; n < N; n++) {
test(n, prev);
prev += cur;
cur ^= prev ^= cur ^= prev;
Expand Down
4 changes: 2 additions & 2 deletions src/GraphTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ void graph_weighted_test(const size_t v, const size_t e) {
}

int main(int argc, char *argv[]) {
const size_t v = get_argv(argc, argv, 1, 5);
const size_t e = get_argv(argc, argv, 2, 10);
const size_t v = 5;
const size_t e = 10;
std::cout << "GraphAdjList" << std::endl;
graph_test<GraphAdjList<size_t>>(v, e);
std::cout << "GraphAdjMatrix" << std::endl;
Expand Down
3 changes: 3 additions & 0 deletions src/RaceExampleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ int test(size_t n) {
}

int main(int argc, char *argv[]) {
if (argc >= 2)
// Valgrind: do not test at all
return 0;
for (int n = 0; n < 2147483647; n++)
if (test(n))
return 0;
Expand Down