Index

lognestmonster / b54160c

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

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
17831 Jan 2020 20:10b54160cAdd test for linting C source filesJosh Stockin1162G

Blob @ lognestmonster / test

text/x-shellscript1244 bytesdownload raw
1#!/usr/bin/env bash
2
3success() {
4 echo -e "\033[92m\033[1m\033[7m${@}\033[0m"
5}
6
7success_lite() {
8 echo -e "\033[92m${@}\033[0m"
9}
10
11error() {
12 echo -e "\033[91m\033[7m\033[1m${@}\033[0m"
13}
14
15warn() {
16 echo -e "\033[93m\033[1m\033[7m${@}\033[0m"
17}
18
19warn_lite() {
20 echo -e "\033[93m${@}\033[0m"
21}
22
23exit_on_error() {
24 if [ $1 -ne 0 ]
25 then
26 error "Error in test. Exiting..."
27 exit $1
28 else
29 success_lite "Success in test."
30 fi
31}
32
33handle() {
34 $1
35 exit_on_error $?
36}
37
38help() {
39 echo "Usage: ./test [help] [c_unit] [size] [lint]"
40}
41
42c_unit() {
43 warn "Running C unit test chain"
44 echo
45
46 # Compile C unit tests
47 warn_lite "Making C header unit test"
48 handle make c_unit
49 echo
50
51 warn_lite "Running C header unit test"
52 handle bin/c
53 echo
54
55 success "Finished"
56}
57
58lint() {
59 warn "Running lint test"
60 echo
61
62 find . -name "*.c" -print0 | while read -d $'\0' file
63 do
64 warn_lite "Executing gcc --syntax-only $file"
65 handle "gcc --syntax-only -pedantic -Wall -Wextra -I src/c $file"
66 echo
67 done
68
69 success "Finished"
70}
71
72size() {
73 warn "Running size test on optimization levels"
74 echo
75
76 warn_lite "Compiling and getting file sizes"
77 handle tests/size.py
78 echo
79
80 success "Finished"
81}
82
83for test in "$@"
84do
85 $test
86done
87
88echo -e "finished: ${SECONDS} seconds"
89