Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
agroce committed Aug 25, 2024
1 parent f4eaa7e commit 43aa76c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
22 changes: 22 additions & 0 deletions test/test_basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import subprocess

import pytest

def test_record_replay():
r = subprocess.call(["gcc -o test/toy toy.c"], shell=True)
assert(r == 0)

with open("out1.txt", 'w') as f:
r = subprocess.call(["mkdir mutants; muttfuzz "./toy" toy --score --avoid_repeats --stop_on_repeat --repeat_retries 2000 --save_results analysis.csv --save_mutants mutants"], shell=True, stdout=f, stderr=f)
assert(r == 0)
with open("out1.txt", 'r') as f:
contents = f.read()
assert("FINAL MUTATION SCORE OVER 14 EXECUTED MUTANTS: 57.14%" in contents)

with open("out2.txt", 'w') as f:
r = subprocess.call(["muttfuzz "./toy" toy --score --avoid_repeats --stop_on_repeat --save_results s_analysis.csv --use_saved_mutants mutants"], shell=True, stdout=f, stderr=f)
assert(r == 0)
with open("out2.txt", 'r') as f:
contents = f.read()
assert("FINAL MUTATION SCORE OVER 14 EXECUTED MUTANTS: 57.14%" in contents)

10 changes: 4 additions & 6 deletions test/toy.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#include <assert.h>

#include <assert.h>

int main() {
int a = 20;
if (a < 10) {
assert(0);
}

if (a > 100) {
assert(0);
}

if (a != 20) {
if (a > 30) {
assert(0);
}
}

0 comments on commit 43aa76c

Please sign in to comment.