-
Notifications
You must be signed in to change notification settings - Fork 5
/
.coveralls.sh
executable file
·793 lines (669 loc) · 25.6 KB
/
.coveralls.sh
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
#!/usr/bin/env sh
# Coverage test and submission script
################################################################################
#
# Version: 2.2.5
#
################################################################################
#
# SPDX-License-Identifier: MIT
#
# Copyright (c) 2018-2024 Ryan M. Lederman <[email protected]>
# Copyright (c) 2018-2024 Jeffrey H. Johnson <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
################################################################################
PATH="/usr/local/bin:/usr/local/sbin:${PATH:-}" && export PATH
################################################################################
set -ex
################################################################################
# How parallel? Use "1" for now.
JOBS=1
################################################################################
# What MAKE to use?
test -n "${MAKE:-}" && DO_MAKE="${MAKE:-}"
################################################################################
# Clean-up
cleanup_files()
{
rm -f ./coverage-out*.* > /dev/null 2>&1
rm -f ./coveralls.json > /dev/null 2>&1
}
cleanup_files
################################################################################
# Make sure we have a token set.
test -n "${COVERALLS_REPO_TOKEN:-}" \
|| {
printf '%s\n' "Error: COVERALLS_REPO_TOKEN is unset."
exit 1
}
################################################################################
# Test for command
test_for()
{
command -v "${1:-}" > /dev/null 2>&1 \
|| {
printf '%s\n' "Error: ${1:-} not found."
exit 1
}
}
################################################################################
# Sanity check.
test_for curl
test_for gcovr
test_for git
################################################################################
# Setup compiler.
CC="ccache gcc"
CFLAGS="-fno-inline -fprofile-arcs -ftest-coverage --coverage"
LDFLAGS="-fprofile-arcs -ftest-coverage"
export CC CFLAGS LDFLAGS
################################################################################
# Removes unwanted results
remove_sample()
{
# shellcheck disable=SC2046
env rm $(find . -name 'plugin_sample*.*gc*' -print) || true
# shellcheck disable=SC2046
env rm $(find . -name 'mcmb*.*gc*' -print) || true
}
################################################################################
# Removes all coverage files
remove_coverage()
{
# shellcheck disable=SC2046
env rm $(find . -name '*.*gc*' -print) || true
sleep 1 || true
}
################################################################################
# Runs gcovr
run_gcovr()
{
gcovr \
--gcov-ignore-parse-errors=negative_hits.warn_once_per_file \
--json "${1}"
}
################################################################################
# Redirect output
test -n "${NO_REDIRECT:-}" \
|| {
exec 5>&1 > coverage-out.txt 2>&1
}
################################################################################
# Run 1 - Debug and self-log
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
build/bin/sirexample || true
build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-1.json
remove_coverage
################################################################################
# Run 2 - No plugins
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1 SIR_NO_PLUGINS=1
build/bin/sirexample || true
build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-2.json
remove_coverage
################################################################################
# Run 3 - Perf test
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1 SIR_NO_PLUGINS=1
build/bin/sirexample || true
build/bin/sirtests --perf || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-3.json
remove_coverage
################################################################################
# Run 4 - Test help
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1 SIR_NO_PLUGINS=1
build/bin/sirexample || true
build/bin/sirtests --help || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-4.json
remove_coverage
################################################################################
# Run 5 - List tests
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1 SIR_NO_PLUGINS=1
build/bin/sirexample || true
build/bin/sirtests --list || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-5.json
remove_coverage
################################################################################
# Run 6 - Version check
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1 SIR_NO_PLUGINS=1
build/bin/sirexample || true
build/bin/sirtests --version || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-6.json
remove_coverage
################################################################################
# Run 7 - Invalid arguments to sirtest
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1 SIR_NO_PLUGINS=1
build/bin/sirexample || true
build/bin/sirtests --INVALID_ARGUMENTS || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-7.json
remove_coverage
################################################################################
# Run 8 - Bad `--only` without arguments to sirtest
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1 SIR_NO_PLUGINS=1
build/bin/sirexample || true
build/bin/sirtests --only || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-8.json
remove_coverage
################################################################################
# Run 9 - No debug and no self-log
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}"
build/bin/sirexample || true
build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-9.json
remove_coverage
################################################################################
# Run 10 - Just self-log
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_SELFLOG=1
build/bin/sirexample || true
build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-10.json
remove_coverage
################################################################################
# Run 11 - Interactive
printf '%s\n' '#!/usr/bin/env expect' > r.sh
# shellcheck disable=SC2129
printf '%s\n' 'spawn ./build/bin/sirtests --wait' >> r.sh
printf '%s\n' 'set timeout 999' >> r.sh
printf '%s\n' 'expect "press any key to exit..."' >> r.sh
printf '%s\n' 'send -- "\r"' >> r.sh
printf '%s\n' 'expect eof' >> r.sh
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_SELFLOG=1
build/bin/sirexample || true
chmod a+x r.sh
./r.sh || true
# shellcheck disable=SC2310
remove_sample || true
rm -f r.sh || true
run_gcovr run-11.json
remove_coverage
################################################################################
# Run 12 - Deny root
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
build/bin/sirexample || true
fakeroot build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-12.json
remove_coverage
################################################################################
# Run 13 - Fail some tests (no logs directory)
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_NO_SYSTEM_LOGGERS=1 SIR_DEBUG=1 SIR_SELFLOG=1
build/bin/sirexample || true
rm -rf logs || true
build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-13.json
remove_coverage
################################################################################
# Run 14 - Fail more.
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_NO_SYSTEM_LOGGERS=1 SIR_DEBUG=1 SIR_SELFLOG=1
build/bin/sirexample || true
build/bin/sirtests --only 0000 || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-14.json
remove_coverage
################################################################################
# Run 15 - Leave logs
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_NO_SYSTEM_LOGGERS=1 SIR_DEBUG=1 SIR_SELFLOG=1
build/bin/sirexample || true
build/bin/sirtests --leave-logs || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-15.json
remove_coverage
################################################################################
# Run 16 - Break readlink function
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_NO_SYSTEM_LOGGERS=1 SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "long readlink() { return -1; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-16.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 17 - Break clock_gettime function
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_NO_SYSTEM_LOGGERS=1 SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "int clock_gettime() { return -1; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-17.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 18 - Break fstat and lstat functions
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_NO_SYSTEM_LOGGERS=1 SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "int fstat() { return -1; }" > bad.c
printf '%s\n' "int lstat() { return -1; }" >> bad.c
gcc -shared -fPIC bad.c -o bad.so
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-18.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 19 - Break fputs function
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_NO_SYSTEM_LOGGERS=1 SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "int fputs() { return -1; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-19.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 20 - Break fseek function
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "int fseek() { return -1; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-20.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 21 - Break fputc function
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "int fputc() { return -1; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-21.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 22 - Break gethostname function
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "int gethostname() { return -1; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-22.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 23 - Break stat functions
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "int stat() { return -1; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-23.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 24 - Break pthread_join function
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "int pthread_join() { return -1; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-24.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 25 - Break pthread_create function
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "int pthread_create() { return -1; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-25.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 26 - Break dlopen function
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "int dlopen() { return 0; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-26.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 27 - Break dlsym function
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "int dlsym() { return 0; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-27.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 28 - Break readdir function
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "#include <stddef.h>" "void* readdir() { return NULL; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-28.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 29 - Break opendir function
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "int opendir() { return 0; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-29.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 30 - Break calloc function
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "int calloc() { return 0; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-30.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 31 - Break time function
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "long time() { return -1; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-31.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 32 - Break strndup function
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "char *strndup() { return 0; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-32.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 33 - Do --only file-archive-large
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
build/bin/sirexample || true
build/bin/sirtests --only file-archive-large || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-33.json
remove_coverage
################################################################################
# Run 34 - Break localtime_r function
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1
printf '%s\n' "long localtime_r() { return 0; }" > bad.c
gcc -shared -fPIC bad.c -o bad.so || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirexample || true
env LD_PRELOAD="$(pwd)/bad.so" build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-34.json
remove_coverage
rm -f bad.c > /dev/null 2>&1
rm -f bad.so > /dev/null 2>&1
################################################################################
# Run 35 - C++ test
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" tests++ SIR_DEBUG=1 SIR_SELFLOG=1 SIR_NO_PLUGINS=1
build/bin/sirexample || true
build/bin/sirtests++ || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-35.json
remove_coverage
################################################################################
# Run 36 - C++ init-cleanup-raii test
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" tests++ SIR_DEBUG=1 SIR_SELFLOG=1 SIR_NO_PLUGINS=1
build/bin/sirexample || true
build/bin/sirtests++ --only init-cleanup-raii || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-36.json
remove_coverage
################################################################################
# Run 37 - C++ bad option test
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" tests++ SIR_DEBUG=1 SIR_SELFLOG=1 SIR_NO_PLUGINS=1
build/bin/sirexample || true
build/bin/sirtests++ --badoptions || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-37.json
remove_coverage
################################################################################
# Run 38 - Interactive
printf '%s\n' '#!/usr/bin/env expect' > r.sh
# shellcheck disable=SC2129
printf '%s\n' 'spawn ./build/bin/sirtests++ --wait' >> r.sh
printf '%s\n' 'set timeout 999' >> r.sh
printf '%s\n' 'expect "press any key to exit..."' >> r.sh
printf '%s\n' 'send -- "\r"' >> r.sh
printf '%s\n' 'expect eof' >> r.sh
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_SELFLOG=1
build/bin/sirexample || true
chmod a+x r.sh
./r.sh || true
# shellcheck disable=SC2310
remove_sample || true
rm -f r.sh || true
run_gcovr run-38.json
remove_coverage
################################################################################
# Run 39 - Debug and self-log with text styling disabled
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1 SIR_NO_TEXT_STYLING=1
build/bin/sirexample || true
build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-39.json
remove_coverage
################################################################################
# Run 40 - Text styling disabled
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_NO_TEXT_STYLING=1
build/bin/sirexample || true
build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-40.json
remove_coverage
################################################################################
# Run 41 - Debug and self-log with CRLF
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1 SIR_USE_EOL_CRLF=1
build/bin/sirexample || true
build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-41.json
remove_coverage
################################################################################
# Run 42 - Debug and self-log with text styling disabled with CRLF
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1 SIR_SELFLOG=1 SIR_NO_TEXT_STYLING=1 SIR_USE_EOL_CRLF=1
build/bin/sirexample || true
build/bin/sirtests || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-42.json
remove_coverage
################################################################################
# Run 43 - Filesystem test without ./build/bin/file.exists existing
"${DO_MAKE:-make}" -j "${JOBS:?}" clean
"${DO_MAKE:-make}" -j "${JOBS:?}" SIR_DEBUG=1
rm -f "./build/bin/file.exists"
build/bin/sirexample || true
build/bin/sirtests --only filesystem || true
# shellcheck disable=SC2310
remove_sample || true
run_gcovr run-43.json
remove_coverage
################################################################################
# Undo redirect
test -n "${NO_REDIRECT:-}" \
|| {
exec 1>&5
}
################################################################################
# Show resulting output file info
ls -l ./run-*.json || true
################################################################################
# Process results
MERGE_MODE="merge-use-line-0"
gcovr \
--add-tracefile "run-*.json" \
--merge-mode-functions="${MERGE_MODE:?}" -u -s \
--gcov-ignore-parse-errors=negative_hits.warn_once_per_file \
--html-details coverage-out.html
gcovr \
--add-tracefile "run-*.json" \
--merge-mode-functions="${MERGE_MODE:?}" -u \
--gcov-ignore-parse-errors=negative_hits.warn_once_per_file \
--coveralls coveralls.json
gcovr \
--add-tracefile "run-*.json" \
--merge-mode-functions="${MERGE_MODE:?}" -u -s \
--gcov-ignore-parse-errors=negative_hits.warn_once_per_file
################################################################################
# Submit results
test -n "${NO_COVERALLS:-}" || \
coveralls coveralls.json -r "${COVERALLS_REPO_TOKEN:?}"
################################################################################
# Cleanup
test -n "${NO_CLEANUP:-}" \
|| {
# shellcheck disable=SC2310
cleanup_files || true
rm -f ./run*.json > /dev/null 2>&1 || true
}
################################################################################