Index

lognestmonster / d727ad6

A general-purpose single-header C logging library and parser for event-based logs. (Incomplete)

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
14625 Nov 2019 18:57237d545Add -Werror flag to gccJosh Stockin111N

Blob @ lognestmonster / test

text/x-shellscript1341 bytesdownload raw
1#!/usr/bin/env bash
2
3mkdir -p bin
4
5py() {
6 python3 $@
7}
8
9success() {
10 echo -e "\033[92m\033[1m\033[7m${@}\033[0m"
11}
12
13success_lite() {
14 echo -e "\033[92m${@}\033[0m"
15}
16
17error() {
18 echo -e "\033[91m\033[7m\033[1m${@}\033[0m"
19}
20
21warn() {
22 echo -e "\033[93m\033[1m\033[7m${@}\033[0m"
23}
24
25warn_lite() {
26 echo -e "\033[93m${@}\033[0m"
27}
28
29run() {
30 warn_lite "python3 ${@}"
31 py $@
32 code=$?
33 if [ ${code} -ne 0 ]
34 then
35 error "Error in test '${@}'. Exiting..."
36 exit ${code}
37 else
38 success_lite "Success in test '${@}'."
39 fi
40 echo
41}
42
43compile_c() {
44 warn_lite "gcc ${@}"
45 gcc $@
46 code=$?
47 if [ ${code} -ne 0 ]
48 then
49 error "Error in test '${@}'. Exiting..."
50 exit ${code}
51 else
52 success_lite "Success in test '${@}'."
53 fi
54 echo
55 warn_lite "bin/c"
56 bin/c
57 code=$?
58 if [ ${code} -ne 0 ]
59 then
60 error "Error in test 'bin/c'. Exiting..."
61 exit ${code}
62 else
63 success_lite "Success in test 'bin/c'."
64 fi
65 echo
66}
67
68run_tests() {
69 # Test prep (generate log files)
70 warn "Undergoing test preparations"
71 run ./tests/write.py ./bin/w1.lnm
72 run ./tests/write_many.py ./bin/w2.lnm 1000
73 echo
74
75 # Unit tests
76 warn "Beginning unit tests"
77 compile_c ./tests/main.c -o ./bin/c -Wall -Wextra -Werror -pedantic -I"./src/c"
78 run ./tests/unit_parserargs.py
79 echo
80
81 success "Finished! Exiting with code 0"
82}
83
84run_tests
85
86echo -e "Time elapsed: ${SECONDS} second(s)"
87