| 1 | #!/bin/sh |
| 2 | |
| 3 | # Copyright (C) 2024 Simon Josefsson <[email protected]> |
| 4 | |
| 5 | # This file is free software: you can redistribute it and/or modify |
| 6 | # it under the terms of the GNU General Public License as published |
| 7 | # by the Free Software Foundation, either version 3 of the License, |
| 8 | # or (at your option) any later version. |
| 9 | # |
| 10 | # This file is distributed in the hope that it will be useful, |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
| 14 | # |
| 15 | # You should have received a copy of the GNU General Public License |
| 16 | # along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 17 | |
| 18 | set -e |
| 19 | |
| 20 | cppi --version |
| 21 | echo "PASS: cppi --version" |
| 22 | cppi --help |
| 23 | echo "PASS: cppi --help" |
| 24 | |
| 25 | man -P cat cppi |
| 26 | echo "PASS: man cppi" |
| 27 | |
| 28 | WORKDIR=$(mktemp -d) |
| 29 | trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM |
| 30 | |
| 31 | cd $WORKDIR |
| 32 | |
| 33 | cat <<EOF > input.c |
| 34 | #include <ntlm.h> |
| 35 | #define FOO |
| 36 | #ifdef FOO |
| 37 | #define BAR |
| 38 | #ifdef BAZ |
| 39 | #define NOP |
| 40 | #endif |
| 41 | #endif |
| 42 | EOF |
| 43 | |
| 44 | cat <<EOF > expect.c |
| 45 | #include <ntlm.h> |
| 46 | #define FOO |
| 47 | #ifdef FOO |
| 48 | # define BAR |
| 49 | # ifdef BAZ |
| 50 | # define NOP |
| 51 | # endif |
| 52 | #endif |
| 53 | EOF |
| 54 | |
| 55 | tail -v -n+0 input.c |
| 56 | tail -v -n+0 expect.c |
| 57 | |
| 58 | cppi input.c > output.c |
| 59 | |
| 60 | tail -v -n+0 output.c |
| 61 | |
| 62 | echo "PASS: cppi" |
| 63 | |
| 64 | diff -ur expect.c output.c |
| 65 | echo "PASS: diff" |
| 66 | |
| 67 | if cppi --check input.c 2> /dev/null; then |
| 68 | echo "FAIL: cppi --check input.c" |
| 69 | exit 1 |
| 70 | fi |
| 71 | echo "PASS: cppi --check input.c" |
| 72 | |
| 73 | if ! cppi --check expect.c; then |
| 74 | echo "FAIL: cppi --check expect.c" |
| 75 | exit 1 |
| 76 | fi |
| 77 | echo "PASS: cppi --check expect.c" |
| 78 | |
| 79 | exit 0 |