-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntests.sh
More file actions
38 lines (28 loc) · 1.23 KB
/
runtests.sh
File metadata and controls
38 lines (28 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Testing shell: Run runtests.sh from the challenge_2 directory using bash
# Like bash runtests.sh, hope this helps!
rm -rf thread_test_folder
mkdir thread_test_folder
cd thread_test_folder
## Test 1: Test if pthread_create returns -1 on exceeding the MAX_THREADS count
# Can probably break this test by just having your code print "Test case passed" but... don't do that
# Create executable
gcc -Wall -Werror -std=gnu99 -O0 -g ../threads.c ../tests/full_threads.c -o testfull
# Run executable
./testfull > test1out.txt
# Check results (should pass even if you implemented error messages)
if [[ "$(cat test1out.txt)" == *"Test case passed" ]];
then echo "Test 1 passed"
else echo "Test 1 failed"
fi
## Test 2: Check if pthread_create is able to create more threads after reaching MAX_THREAD
## count and exiting some threads (like creates 128 threads, frees some, then can make more)
# Create executable
gcc -Wall -Werror -std=gnu99 -O0 -g ../threads.c ../tests/makemore.c -o testmakemore
# Run executable
./testmakemore > test2out.txt
# Check results (should pass even if you implemented error messages)
if [[ "$(cat test2out.txt)" == *"Test case passed" ]];
then echo "Test 1 passed"
else echo "Test 1 failed"
fi