diff --git a/.cirrus.yml b/.cirrus.yml index 61aa7198..f97c14af 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -11,7 +11,7 @@ main_freebsd_task: - pkg install --yes autoconf automake libtool main_build_script: - ./autogen.sh - - ./configure --enable-debug --enable-tests CFLAGS='-O3' + - ./configure --enable-debug --enable-checks CFLAGS='-O3' - make - sudo make install main_test_script: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 09bff5a0..8e0c4e4d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,6 +7,19 @@ on: branches: [master] jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: dependencies + run: sudo apt-get --yes install cppcheck + - name: autogen + run: ./autogen.sh + - name: configure + run: ./configure --enable-checks-cppcheck + - name: cppcheck + run: make check-cppcheck + test: runs-on: ubuntu-latest strategy: @@ -21,7 +34,7 @@ jobs: - name: autogen run: ./autogen.sh - name: configure - run: ./configure ${{matrix.debug}} --enable-tests --enable-tests-python CC='${{matrix.cc}}' CFLAGS='${{matrix.opt}}' + run: ./configure ${{matrix.debug}} --enable-checks --enable-checks-python CC='${{matrix.cc}}' CFLAGS='${{matrix.opt}}' - name: make run: make - name: check @@ -63,7 +76,7 @@ jobs: - name: autogen run: ./autogen.sh - name: configure - run: ./configure --host='${{matrix.cross.arch}}-unknown-elf' --enable-tests --enable-tests-python AR='${{matrix.cross.cprefix}}ar' CC='${{matrix.cross.cprefix}}gcc' LD='${{matrix.cross.cprefix}}ld' RANLIB='${{matrix.cross.cprefix}}ranlib' + run: ./configure --host='${{matrix.cross.arch}}-unknown-elf' --enable-checks --enable-checks-python AR='${{matrix.cross.cprefix}}ar' CC='${{matrix.cross.cprefix}}gcc' LD='${{matrix.cross.cprefix}}ld' RANLIB='${{matrix.cross.cprefix}}ranlib' - name: make run: make - name: check @@ -86,7 +99,7 @@ jobs: - name: autogen run: ./autogen.sh - name: configure - run: ./configure --enable-debug --enable-tests --enable-tests-python --without-${{matrix.packages.without}} ${{matrix.packages.dependencies}} + run: ./configure --enable-debug --enable-checks --enable-checks-python --without-${{matrix.packages.without}} ${{matrix.packages.dependencies}} - name: make run: make - name: check @@ -123,19 +136,10 @@ jobs: - name: extract run: tar -xzf "libkernaux-$(cat VERSION).tar.gz" - name: configure - run: cd "libkernaux-$(cat VERSION)" && ./configure --enable-debug --enable-tests --enable-tests-python + run: cd "libkernaux-$(cat VERSION)" && ./configure --enable-debug --enable-checks --enable-checks-python - name: make run: cd "libkernaux-$(cat VERSION)" && make - name: check run: cd "libkernaux-$(cat VERSION)" && make check || (./test-suite-log && false) - name: install run: cd "libkernaux-$(cat VERSION)" && sudo make install - - cppcheck: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: dependencies - run: sudo apt-get --yes install cppcheck - - name: cppcheck - run: cppcheck --quiet --error-exitcode=1 --std=c99 --enable=warning,style,performance,portability --inline-suppr examples/ include/ libc/ src/ tests/ diff --git a/ChangeLog b/ChangeLog index bf6bb203..fc36702c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2022-12-02 Alex Kotov + + * configure.ac: Rename args "--enable-tests*" to "--enable-checks*" + * configure.ac: Add arg "--enable-checks-cppcheck" + 2022-12-01 Alex Kotov * src/printf.c: Fix a bug with too big float precision diff --git a/Makefile.am b/Makefile.am index b7d28570..9441d17c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,7 +12,7 @@ endif SUBDIRS += . -if ENABLE_TESTS +if ENABLE_CHECKS SUBDIRS += examples tests endif @@ -23,6 +23,22 @@ AM_CFLAGS += -DKERNAUX_ACCESS_PRIVATE lib_LTLIBRARIES = libkernaux.la +########## +# Checks # +########## + +MY_CHECKS = +check: $(MY_CHECKS) + +if ENABLE_CHECKS_CPPCHECK +MY_CHECKS += check-cppcheck +check-cppcheck: + $(CPPCHECK) $(CPPCHECK_ARGS) $(CPPCHECK_PATHS) + +CPPCHECK_ARGS = --quiet --error-exitcode=1 --std=c99 --inline-suppr --enable=warning,style,performance,portability +CPPCHECK_PATHS = examples/ include/ libc/ src/ tests/ +endif + ################## # Required files # ################## diff --git a/README.md b/README.md index d930fd07..d7bbe82c 100644 --- a/README.md +++ b/README.md @@ -136,9 +136,9 @@ stable options. #### Features -* `--enable-tests` - enable usual tests and examples -* `--enable-tests-all` - enable all tests -* `--enable-tests-python` - enable tests that require Python 3 with YAML and +* `--enable-checks` - enable usual tests and examples +* `--enable-checks-all` - enable all tests +* `--enable-checks-python` - enable tests that require Python 3 with YAML and Jinja2 #### Packages @@ -192,7 +192,7 @@ environment. ``` ./autogen.sh # if present -./configure --enable-tests # or --enable-tests-all, but see prerequisites +./configure --enable-checks # or --enable-checks-all, but see prerequisites make ``` diff --git a/config/dev-native b/config/dev-native index dec0593d..effcd78a 100755 --- a/config/dev-native +++ b/config/dev-native @@ -7,4 +7,4 @@ if [ -f "$REPO/Makefile" ]; then make -C "$REPO" distclean; fi PREFIX="$REPO/dest/dev-native" -"$REPO/configure" --prefix="$PREFIX" --enable-tests-all +"$REPO/configure" --prefix="$PREFIX" --enable-checks-all diff --git a/config/root-native b/config/root-native index eacfc501..06b42c74 100755 --- a/config/root-native +++ b/config/root-native @@ -5,4 +5,4 @@ set -eux REPO="$(realpath "$(dirname "$(realpath "$0")")/..")" if [ -f "$REPO/Makefile" ]; then make -C "$REPO" distclean; fi -"$REPO/configure" --enable-tests +"$REPO/configure" --enable-checks diff --git a/configure.ac b/configure.ac index c8dad833..83da5fa1 100644 --- a/configure.ac +++ b/configure.ac @@ -43,39 +43,40 @@ AC_CONFIG_FILES([ ############### dnl Features (enabled by default) -AC_ARG_ENABLE([debug], AS_HELP_STRING([--disable-debug], [disable debugging])) -AC_ARG_ENABLE([float], AS_HELP_STRING([--disable-float], [disable floating-point arithmetic])) -AC_ARG_ENABLE([werror], AS_HELP_STRING([--disable-werror], [disable -Werror])) - +AC_ARG_ENABLE([debug], AS_HELP_STRING([--disable-debug], [disable debugging])) +AC_ARG_ENABLE([float], AS_HELP_STRING([--disable-float], [disable floating-point arithmetic])) +AC_ARG_ENABLE([werror], AS_HELP_STRING([--disable-werror], [disable -Werror])) + dnl Features (disabled by default) -AC_ARG_ENABLE([freestanding], AS_HELP_STRING([--enable-freestanding], [build for freestanding environment])) -AC_ARG_ENABLE([split-libc], AS_HELP_STRING([--enable-split-libc], [split off libc])) -AC_ARG_ENABLE([tests], AS_HELP_STRING([--enable-tests], [enable usual tests and examples])) -AC_ARG_ENABLE([tests-all], AS_HELP_STRING([--enable-tests-all], [enable all tests])) -AC_ARG_ENABLE([tests-python], AS_HELP_STRING([--enable-tests-python], [enable tests that require Python 3 with YAML and Jinja2])) +AC_ARG_ENABLE([freestanding], AS_HELP_STRING([--enable-freestanding], [build for freestanding environment])) +AC_ARG_ENABLE([split-libc], AS_HELP_STRING([--enable-split-libc], [split off libc])) +AC_ARG_ENABLE([checks], AS_HELP_STRING([--enable-checks], [enable usual tests and examples])) +AC_ARG_ENABLE([checks-all], AS_HELP_STRING([--enable-checks-all], [enable all checks])) +AC_ARG_ENABLE([checks-cppcheck], AS_HELP_STRING([--enable-checks-cppcheck], [enable cppcheck])) +AC_ARG_ENABLE([checks-python], AS_HELP_STRING([--enable-checks-python], [enable tests that require Python 3 with YAML and Jinja2])) dnl Packages (enabled by default) -AC_ARG_WITH( [all], AS_HELP_STRING([--without-all], [without all default packages])) -AC_ARG_WITH( [arch-all], AS_HELP_STRING([--without-arch-all], [without all architectures])) -AC_ARG_WITH( [arch-i386], AS_HELP_STRING([--without-arch-i386], [without architecture i386])) -AC_ARG_WITH( [arch-riscv64], AS_HELP_STRING([--without-arch-riscv64], [without architecture riscv64])) -AC_ARG_WITH( [arch-x86-64], AS_HELP_STRING([--without-arch-x86-64], [without architecture x86-64])) -AC_ARG_WITH( [asm], AS_HELP_STRING([--without-asm], [without kernel assembler helpers])) -AC_ARG_WITH( [cmdline], AS_HELP_STRING([--without-cmdline], [without command line parser])) -AC_ARG_WITH( [elf], AS_HELP_STRING([--without-elf], [without ELF utils])) -AC_ARG_WITH( [free-list], AS_HELP_STRING([--without-free-list], [without free list memory allocator])) -AC_ARG_WITH( [mbr], AS_HELP_STRING([--without-mbr], [without MBR utils])) -AC_ARG_WITH( [memmap], AS_HELP_STRING([--without-memmap], [without memory map])) -AC_ARG_WITH( [multiboot2], AS_HELP_STRING([--without-multiboot2], [without Multiboot 2 information parser])) -AC_ARG_WITH( [ntoa], AS_HELP_STRING([--without-ntoa], [without itoa/ftoa])) -AC_ARG_WITH( [pfa], AS_HELP_STRING([--without-pfa], [without Page Frame Allocator])) -AC_ARG_WITH( [printf], AS_HELP_STRING([--without-printf], [without printf])) -AC_ARG_WITH( [printf-fmt], AS_HELP_STRING([--without-printf-fmt], [without printf format parser])) -AC_ARG_WITH( [units], AS_HELP_STRING([--without-units], [without measurement units utils])) +AC_ARG_WITH( [all], AS_HELP_STRING([--without-all], [without all default packages])) +AC_ARG_WITH( [arch-all], AS_HELP_STRING([--without-arch-all], [without all architectures])) +AC_ARG_WITH( [arch-i386], AS_HELP_STRING([--without-arch-i386], [without architecture i386])) +AC_ARG_WITH( [arch-riscv64], AS_HELP_STRING([--without-arch-riscv64], [without architecture riscv64])) +AC_ARG_WITH( [arch-x86-64], AS_HELP_STRING([--without-arch-x86-64], [without architecture x86-64])) +AC_ARG_WITH( [asm], AS_HELP_STRING([--without-asm], [without kernel assembler helpers])) +AC_ARG_WITH( [cmdline], AS_HELP_STRING([--without-cmdline], [without command line parser])) +AC_ARG_WITH( [elf], AS_HELP_STRING([--without-elf], [without ELF utils])) +AC_ARG_WITH( [free-list], AS_HELP_STRING([--without-free-list], [without free list memory allocator])) +AC_ARG_WITH( [mbr], AS_HELP_STRING([--without-mbr], [without MBR utils])) +AC_ARG_WITH( [memmap], AS_HELP_STRING([--without-memmap], [without memory map])) +AC_ARG_WITH( [multiboot2], AS_HELP_STRING([--without-multiboot2], [without Multiboot 2 information parser])) +AC_ARG_WITH( [ntoa], AS_HELP_STRING([--without-ntoa], [without itoa/ftoa])) +AC_ARG_WITH( [pfa], AS_HELP_STRING([--without-pfa], [without Page Frame Allocator])) +AC_ARG_WITH( [printf], AS_HELP_STRING([--without-printf], [without printf])) +AC_ARG_WITH( [printf-fmt], AS_HELP_STRING([--without-printf-fmt], [without printf format parser])) +AC_ARG_WITH( [units], AS_HELP_STRING([--without-units], [without measurement units utils])) dnl Packages (disabled by default) -AC_ARG_WITH( [drivers], AS_HELP_STRING([--with-drivers], [with drivers])) -AC_ARG_WITH( [libc], AS_HELP_STRING([--with-libc], [with libc replacement])) +AC_ARG_WITH( [drivers], AS_HELP_STRING([--with-drivers], [with drivers])) +AC_ARG_WITH( [libc], AS_HELP_STRING([--with-libc], [with libc replacement])) @@ -83,12 +84,13 @@ AC_ARG_WITH( [libc], AS_HELP_STRING([--with-libc], [with lib # Default args # ################ -AC_DEFUN([do_enable_tests_all], +AC_DEFUN([do_enable_checks_all], [ -if test -z "$enable_tests"; then enable_tests=yes; fi -if test -z "$enable_tests_python"; then enable_tests_python=yes; fi +if test -z "$enable_checks"; then enable_checks=yes; fi +if test -z "$enable_checks_cppcheck"; then enable_checks_cppcheck=yes; fi +if test -z "$enable_checks_python"; then enable_checks_python=yes; fi ]) -AS_IF([test "$enable_tests_all" = yes], do_enable_tests_all) +AS_IF([test "$enable_checks_all" = yes], do_enable_checks_all) AC_DEFUN([do_without_arch_all], [ @@ -125,39 +127,40 @@ AS_IF([test "$with_all" = no], do_without_all) ################## dnl Features (enabled by default) -AS_IF([test "$enable_debug" = no ], [enable_debug=no], [enable_debug=yes]) -AS_IF([test "$enable_float" = no ], [enable_float=no], [enable_float=yes]) -AS_IF([test "$enable_werror" = no ], [enable_werror=no], [enable_werror=yes]) +AS_IF([test "$enable_debug" = no ], [enable_debug=no], [enable_debug=yes]) +AS_IF([test "$enable_float" = no ], [enable_float=no], [enable_float=yes]) +AS_IF([test "$enable_werror" = no ], [enable_werror=no], [enable_werror=yes]) dnl Features (disabled by default) -AS_IF([test "$enable_freestanding" = yes], [enable_freestanding=yes], [enable_freestanding=no]) -AS_IF([test "$enable_split_libc" = yes], [enable_split_libc=yes], [enable_split_libc=no]) -AS_IF([test "$enable_tests" = yes], [enable_tests=yes], [enable_tests=no]) -AS_IF([test "$enable_tests_all" = yes], [enable_tests_all=yes], [enable_tests_all=no]) -AS_IF([test "$enable_tests_python" = yes], [enable_tests_python=yes], [enable_tests_python=no]) +AS_IF([test "$enable_freestanding" = yes], [enable_freestanding=yes], [enable_freestanding=no]) +AS_IF([test "$enable_split_libc" = yes], [enable_split_libc=yes], [enable_split_libc=no]) +AS_IF([test "$enable_checks" = yes], [enable_checks=yes], [enable_checks=no]) +AS_IF([test "$enable_checks_all" = yes], [enable_checks_all=yes], [enable_checks_all=no]) +AS_IF([test "$enable_checks_cppcheck" = yes], [enable_checks_cppcheck=yes], [enable_checks_cppcheck=no]) +AS_IF([test "$enable_checks_python" = yes], [enable_checks_python=yes], [enable_checks_python=no]) dnl Packages (enabled by default) -AS_IF([test "$with_all" = no ], [with_all=no], [with_all=yes]) -AS_IF([test "$with_arch_all" = no ], [with_arch_all=no], [with_arch_all=yes]) -AS_IF([test "$with_arch_i386" = no ], [with_arch_i386=no], [with_arch_i386=yes]) -AS_IF([test "$with_arch_riscv64" = no ], [with_arch_riscv64=no], [with_arch_riscv64=yes]) -AS_IF([test "$with_arch_x86_64" = no ], [with_arch_x86_64=no], [with_arch_x86_64=yes]) -AS_IF([test "$with_asm" = no ], [with_asm=no], [with_asm=yes]) -AS_IF([test "$with_cmdline" = no ], [with_cmdline=no], [with_cmdline=yes]) -AS_IF([test "$with_elf" = no ], [with_elf=no], [with_elf=yes]) -AS_IF([test "$with_free_list" = no ], [with_free_list=no], [with_free_list=yes]) -AS_IF([test "$with_mbr" = no ], [with_mbr=no], [with_mbr=yes]) -AS_IF([test "$with_memmap" = no ], [with_memmap=no], [with_memmap=yes]) -AS_IF([test "$with_multiboot2" = no ], [with_multiboot2=no], [with_multiboot2=yes]) -AS_IF([test "$with_ntoa" = no ], [with_ntoa=no], [with_ntoa=yes]) -AS_IF([test "$with_pfa" = no ], [with_pfa=no], [with_pfa=yes]) -AS_IF([test "$with_printf" = no ], [with_printf=no], [with_printf=yes]) -AS_IF([test "$with_printf_fmt" = no ], [with_printf_fmt=no], [with_printf_fmt=yes]) -AS_IF([test "$with_units" = no ], [with_units=no], [with_units=yes]) +AS_IF([test "$with_all" = no ], [with_all=no], [with_all=yes]) +AS_IF([test "$with_arch_all" = no ], [with_arch_all=no], [with_arch_all=yes]) +AS_IF([test "$with_arch_i386" = no ], [with_arch_i386=no], [with_arch_i386=yes]) +AS_IF([test "$with_arch_riscv64" = no ], [with_arch_riscv64=no], [with_arch_riscv64=yes]) +AS_IF([test "$with_arch_x86_64" = no ], [with_arch_x86_64=no], [with_arch_x86_64=yes]) +AS_IF([test "$with_asm" = no ], [with_asm=no], [with_asm=yes]) +AS_IF([test "$with_cmdline" = no ], [with_cmdline=no], [with_cmdline=yes]) +AS_IF([test "$with_elf" = no ], [with_elf=no], [with_elf=yes]) +AS_IF([test "$with_free_list" = no ], [with_free_list=no], [with_free_list=yes]) +AS_IF([test "$with_mbr" = no ], [with_mbr=no], [with_mbr=yes]) +AS_IF([test "$with_memmap" = no ], [with_memmap=no], [with_memmap=yes]) +AS_IF([test "$with_multiboot2" = no ], [with_multiboot2=no], [with_multiboot2=yes]) +AS_IF([test "$with_ntoa" = no ], [with_ntoa=no], [with_ntoa=yes]) +AS_IF([test "$with_pfa" = no ], [with_pfa=no], [with_pfa=yes]) +AS_IF([test "$with_printf" = no ], [with_printf=no], [with_printf=yes]) +AS_IF([test "$with_printf_fmt" = no ], [with_printf_fmt=no], [with_printf_fmt=yes]) +AS_IF([test "$with_units" = no ], [with_units=no], [with_units=yes]) dnl Packages (disabled by default) -AS_IF([test "$with_drivers" = yes], [with_drivers=yes], [with_drivers=no]) -AS_IF([test "$with_libc" = yes], [with_libc=yes], [with_libc=no]) +AS_IF([test "$with_drivers" = yes], [with_drivers=yes], [with_drivers=no]) +AS_IF([test "$with_libc" = yes], [with_libc=yes], [with_libc=no]) @@ -165,10 +168,10 @@ AS_IF([test "$with_libc" = yes], [with_libc=yes], [with_libc # Test args # ############# -AS_IF([test "$enable_tests" = yes -a "$enable_freestanding" = yes], AC_MSG_ERROR([can not build freestanding tests])) -AS_IF([test "$enable_tests_python" = yes -a "$enable_freestanding" = yes], AC_MSG_ERROR([can not build freestanding tests])) -AS_IF([test "$enable_tests" = yes -a "$with_libc" = yes], AC_MSG_ERROR([can not use package `libc' with tests])) -AS_IF([test "$enable_tests_python" = yes -a "$with_libc" = yes], AC_MSG_ERROR([can not use package `libc' with tests])) +AS_IF([test "$enable_checks" = yes -a "$enable_freestanding" = yes], AC_MSG_ERROR([can not build freestanding tests])) +AS_IF([test "$enable_checks_python" = yes -a "$enable_freestanding" = yes], AC_MSG_ERROR([can not build freestanding tests])) +AS_IF([test "$enable_checks" = yes -a "$with_libc" = yes], AC_MSG_ERROR([can not use package `libc' with tests])) +AS_IF([test "$enable_checks_python" = yes -a "$with_libc" = yes], AC_MSG_ERROR([can not use package `libc' with tests])) AS_IF([test "$with_printf" = yes -a "$with_ntoa" = no], AC_MSG_ERROR([package `printf' requires package `ntoa'])) AS_IF([test "$with_printf" = yes -a "$with_printf_fmt" = no], AC_MSG_ERROR([package `printf' requires package `printf-fmt'])) @@ -181,47 +184,48 @@ AS_IF([test "$with_units" = yes -a "$with_ntoa" = no], AC_MSG_ERROR([pack ######################### dnl Architecture -AM_CONDITIONAL([ASM_I386], [test "$host_cpu" = i386]) -AM_CONDITIONAL([ASM_RISCV64], [test "$host_cpu" = riscv64]) -AM_CONDITIONAL([ASM_X86_64], [test "$host_cpu" = x86_64]) +AM_CONDITIONAL([ASM_I386], [test "$host_cpu" = i386]) +AM_CONDITIONAL([ASM_RISCV64], [test "$host_cpu" = riscv64]) +AM_CONDITIONAL([ASM_X86_64], [test "$host_cpu" = x86_64]) dnl Architecture (additional) -AM_CONDITIONAL([ASM_X86], [test "$host_cpu" = i386 -o "$host_cpu" = x86_64]) +AM_CONDITIONAL([ASM_X86], [test "$host_cpu" = i386 -o "$host_cpu" = x86_64]) dnl Features (enabled by default) -AM_CONDITIONAL([ENABLE_DEBUG], [test "$enable_debug" = yes]) -AM_CONDITIONAL([ENABLE_FLOAT], [test "$enable_float" = yes]) -AM_CONDITIONAL([ENABLE_WERROR], [test "$enable_werror" = yes]) +AM_CONDITIONAL([ENABLE_DEBUG], [test "$enable_debug" = yes]) +AM_CONDITIONAL([ENABLE_FLOAT], [test "$enable_float" = yes]) +AM_CONDITIONAL([ENABLE_WERROR], [test "$enable_werror" = yes]) dnl Features (disabled by default) -AM_CONDITIONAL([ENABLE_FREESTANDING], [test "$enable_freestanding" = yes]) -AM_CONDITIONAL([ENABLE_SPLIT_LIBC], [test "$enable_split_libc" = yes]) -AM_CONDITIONAL([ENABLE_TESTS], [test "$enable_tests" = yes]) -AM_CONDITIONAL([ENABLE_TESTS_PYTHON], [test "$enable_tests_python" = yes]) +AM_CONDITIONAL([ENABLE_FREESTANDING], [test "$enable_freestanding" = yes]) +AM_CONDITIONAL([ENABLE_SPLIT_LIBC], [test "$enable_split_libc" = yes]) +AM_CONDITIONAL([ENABLE_CHECKS], [test "$enable_checks" = yes]) +AM_CONDITIONAL([ENABLE_CHECKS_CPPCHECK], [test "$enable_checks_cppcheck" = yes]) +AM_CONDITIONAL([ENABLE_CHECKS_PYTHON], [test "$enable_checks_python" = yes]) dnl Packages (enabled by default) -AM_CONDITIONAL([WITH_ARCH_I386], [test "$with_arch_i386" = yes]) -AM_CONDITIONAL([WITH_ARCH_RISCV64], [test "$with_arch_riscv64" = yes]) -AM_CONDITIONAL([WITH_ARCH_X86_64], [test "$with_arch_x86_64" = yes]) -AM_CONDITIONAL([WITH_ASM], [test "$with_asm" = yes]) -AM_CONDITIONAL([WITH_CMDLINE], [test "$with_cmdline" = yes]) -AM_CONDITIONAL([WITH_ELF], [test "$with_elf" = yes]) -AM_CONDITIONAL([WITH_FREE_LIST], [test "$with_free_list" = yes]) -AM_CONDITIONAL([WITH_MBR], [test "$with_mbr" = yes]) -AM_CONDITIONAL([WITH_MEMMAP], [test "$with_memmap" = yes]) -AM_CONDITIONAL([WITH_MULTIBOOT2], [test "$with_multiboot2" = yes]) -AM_CONDITIONAL([WITH_NTOA], [test "$with_ntoa" = yes]) -AM_CONDITIONAL([WITH_PFA], [test "$with_pfa" = yes]) -AM_CONDITIONAL([WITH_PRINTF], [test "$with_printf" = yes]) -AM_CONDITIONAL([WITH_PRINTF_FMT], [test "$with_printf_fmt" = yes]) -AM_CONDITIONAL([WITH_UNITS], [test "$with_units" = yes]) +AM_CONDITIONAL([WITH_ARCH_I386], [test "$with_arch_i386" = yes]) +AM_CONDITIONAL([WITH_ARCH_RISCV64], [test "$with_arch_riscv64" = yes]) +AM_CONDITIONAL([WITH_ARCH_X86_64], [test "$with_arch_x86_64" = yes]) +AM_CONDITIONAL([WITH_ASM], [test "$with_asm" = yes]) +AM_CONDITIONAL([WITH_CMDLINE], [test "$with_cmdline" = yes]) +AM_CONDITIONAL([WITH_ELF], [test "$with_elf" = yes]) +AM_CONDITIONAL([WITH_FREE_LIST], [test "$with_free_list" = yes]) +AM_CONDITIONAL([WITH_MBR], [test "$with_mbr" = yes]) +AM_CONDITIONAL([WITH_MEMMAP], [test "$with_memmap" = yes]) +AM_CONDITIONAL([WITH_MULTIBOOT2], [test "$with_multiboot2" = yes]) +AM_CONDITIONAL([WITH_NTOA], [test "$with_ntoa" = yes]) +AM_CONDITIONAL([WITH_PFA], [test "$with_pfa" = yes]) +AM_CONDITIONAL([WITH_PRINTF], [test "$with_printf" = yes]) +AM_CONDITIONAL([WITH_PRINTF_FMT], [test "$with_printf_fmt" = yes]) +AM_CONDITIONAL([WITH_UNITS], [test "$with_units" = yes]) dnl Packages (disabled by default) -AM_CONDITIONAL([WITH_DRIVERS], [test "$with_drivers" = yes]) -AM_CONDITIONAL([WITH_LIBC], [test "$with_libc" = yes]) +AM_CONDITIONAL([WITH_DRIVERS], [test "$with_drivers" = yes]) +AM_CONDITIONAL([WITH_LIBC], [test "$with_libc" = yes]) dnl Packages (virtual) -AM_CONDITIONAL([WITH_ARCH_X86], [test "$with_arch_i386" = yes -o "$with_arch_x86_64" = yes]) +AM_CONDITIONAL([WITH_ARCH_X86], [test "$with_arch_i386" = yes -o "$with_arch_x86_64" = yes]) @@ -230,52 +234,53 @@ AM_CONDITIONAL([WITH_ARCH_X86], [test "$with_arch_i386" = yes -o "$with_ar #################### dnl Architecture -AS_IF([test "$host_cpu" = i386], [AC_DEFINE([ASM_I386], [1], [architecture is i386])]) -AS_IF([test "$host_cpu" = riscv64], [AC_DEFINE([ASM_RISCV64], [1], [architecture is RISC-V 64-bit])]) -AS_IF([test "$host_cpu" = x86_64], [AC_DEFINE([ASM_X86_64], [1], [architecture is x86_64])]) +AS_IF([test "$host_cpu" = i386], [AC_DEFINE([ASM_I386], [1], [architecture is i386])]) +AS_IF([test "$host_cpu" = riscv64], [AC_DEFINE([ASM_RISCV64], [1], [architecture is RISC-V 64-bit])]) +AS_IF([test "$host_cpu" = x86_64], [AC_DEFINE([ASM_X86_64], [1], [architecture is x86_64])]) dnl Architecture (additional) -AS_IF([test "$host_cpu" = i386], [AC_DEFINE([ASM_X86], [1], [architecture is x86])]) -AS_IF([test "$host_cpu" = x86_64], [AC_DEFINE([ASM_X86], [1], [architecture is x86])]) +AS_IF([test "$host_cpu" = i386], [AC_DEFINE([ASM_X86], [1], [architecture is x86])]) +AS_IF([test "$host_cpu" = x86_64], [AC_DEFINE([ASM_X86], [1], [architecture is x86])]) dnl Features (enabled by default) -AS_IF([test "$enable_debug" = yes], [AC_DEFINE([ENABLE_DEBUG], [1], [enabled debugging])]) -AS_IF([test "$enable_float" = yes], [AC_DEFINE([ENABLE_FLOAT], [1], [enabled floating-point arithmetic])]) -AS_IF([test "$enable_werror" = yes], [AC_DEFINE([ENABLE_WERROR], [1], [enabled -Werror])]) +AS_IF([test "$enable_debug" = yes], [AC_DEFINE([ENABLE_DEBUG], [1], [enabled debugging])]) +AS_IF([test "$enable_float" = yes], [AC_DEFINE([ENABLE_FLOAT], [1], [enabled floating-point arithmetic])]) +AS_IF([test "$enable_werror" = yes], [AC_DEFINE([ENABLE_WERROR], [1], [enabled -Werror])]) dnl Features (disabled by default) -AS_IF([test "$enable_split_libc" = yes], [AC_DEFINE([ENABLE_SPLIT_LIBC], [1], [split off libc])]) -AS_IF([test "$enable_freestanding" = yes], [AC_DEFINE([ENABLE_FREESTANDING], [1], [build for freestanding environment])]) -AS_IF([test "$enable_tests" = yes], [AC_DEFINE([ENABLE_TESTS], [1], [enabled usual tests and examples])]) -AS_IF([test "$enable_tests_python" = yes], [AC_DEFINE([ENABLE_TESTS_PYTHON], [1], [enabled tests that require Python 3 with YAML and Jinja2])]) +AS_IF([test "$enable_split_libc" = yes], [AC_DEFINE([ENABLE_SPLIT_LIBC], [1], [split off libc])]) +AS_IF([test "$enable_freestanding" = yes], [AC_DEFINE([ENABLE_FREESTANDING], [1], [build for freestanding environment])]) +AS_IF([test "$enable_checks" = yes], [AC_DEFINE([ENABLE_CHECKS], [1], [enabled usual tests and examples])]) +AS_IF([test "$enable_checks_cppcheck" = yes], [AC_DEFINE([ENABLE_CHECKS_CPPCHECK], [1], [enabled cppcheck])]) +AS_IF([test "$enable_checks_python" = yes], [AC_DEFINE([ENABLE_CHECKS_PYTHON], [1], [enabled tests that require Python 3 with YAML and Jinja2])]) dnl Packages (enabled by default) -AS_IF([test "$with_arch_i386" = yes], [AC_DEFINE([WITH_ARCH_I386], [1], [with architecture i386])]) -AS_IF([test "$with_arch_riscv64" = yes], [AC_DEFINE([WITH_ARCH_RISCV64], [1], [with architecture riscv64])]) -AS_IF([test "$with_arch_x86_64" = yes], [AC_DEFINE([WITH_ARCH_X86_64], [1], [with architecture x86_64])]) -AS_IF([test "$with_asm" = yes], [AC_DEFINE([WITH_ASM], [1], [with kernel assembler helpers])]) -AS_IF([test "$with_cmdline" = yes], [AC_DEFINE([WITH_CMDLINE], [1], [with command line parser])]) -AS_IF([test "$with_elf" = yes], [AC_DEFINE([WITH_ELF], [1], [with ELF utils])]) -AS_IF([test "$with_free_list" = yes], [AC_DEFINE([WITH_FREE_LIST], [1], [with free list memory allocator])]) -AS_IF([test "$with_mbr" = yes], [AC_DEFINE([WITH_MBR], [1], [with MBR utils])]) -AS_IF([test "$with_memmap" = yes], [AC_DEFINE([WITH_MEMMAP], [1], [with memory map])]) -AS_IF([test "$with_multiboot2" = yes], [AC_DEFINE([WITH_MULTIBOOT2], [1], [with Multiboot 2 information parser])]) -AS_IF([test "$with_ntoa" = yes], [AC_DEFINE([WITH_NTOA], [1], [with ntoa])]) -AS_IF([test "$with_pfa" = yes], [AC_DEFINE([WITH_PFA], [1], [with Page Frame Allocator])]) -AS_IF([test "$with_printf" = yes], [AC_DEFINE([WITH_PRINTF], [1], [with printf])]) -AS_IF([test "$with_printf_fmt" = yes], [AC_DEFINE([WITH_PRINTF_FMT], [1], [with printf format parser])]) -AS_IF([test "$with_units", = yes], [AC_DEFINE([WITH_UNITS], [1], [with measurement units utils])]) +AS_IF([test "$with_arch_i386" = yes], [AC_DEFINE([WITH_ARCH_I386], [1], [with architecture i386])]) +AS_IF([test "$with_arch_riscv64" = yes], [AC_DEFINE([WITH_ARCH_RISCV64], [1], [with architecture riscv64])]) +AS_IF([test "$with_arch_x86_64" = yes], [AC_DEFINE([WITH_ARCH_X86_64], [1], [with architecture x86_64])]) +AS_IF([test "$with_asm" = yes], [AC_DEFINE([WITH_ASM], [1], [with kernel assembler helpers])]) +AS_IF([test "$with_cmdline" = yes], [AC_DEFINE([WITH_CMDLINE], [1], [with command line parser])]) +AS_IF([test "$with_elf" = yes], [AC_DEFINE([WITH_ELF], [1], [with ELF utils])]) +AS_IF([test "$with_free_list" = yes], [AC_DEFINE([WITH_FREE_LIST], [1], [with free list memory allocator])]) +AS_IF([test "$with_mbr" = yes], [AC_DEFINE([WITH_MBR], [1], [with MBR utils])]) +AS_IF([test "$with_memmap" = yes], [AC_DEFINE([WITH_MEMMAP], [1], [with memory map])]) +AS_IF([test "$with_multiboot2" = yes], [AC_DEFINE([WITH_MULTIBOOT2], [1], [with Multiboot 2 information parser])]) +AS_IF([test "$with_ntoa" = yes], [AC_DEFINE([WITH_NTOA], [1], [with ntoa])]) +AS_IF([test "$with_pfa" = yes], [AC_DEFINE([WITH_PFA], [1], [with Page Frame Allocator])]) +AS_IF([test "$with_printf" = yes], [AC_DEFINE([WITH_PRINTF], [1], [with printf])]) +AS_IF([test "$with_printf_fmt" = yes], [AC_DEFINE([WITH_PRINTF_FMT], [1], [with printf format parser])]) +AS_IF([test "$with_units", = yes], [AC_DEFINE([WITH_UNITS], [1], [with measurement units utils])]) dnl Packages (disabled by default) -AS_IF([test "$with_drivers" = yes], [AC_DEFINE([WITH_DRIVERS], [1], [with drivers])]) -AS_IF([test "$with_libc" = yes], [AC_DEFINE([WITH_LIBC], [1], [with libc replacement])]) +AS_IF([test "$with_drivers" = yes], [AC_DEFINE([WITH_DRIVERS], [1], [with drivers])]) +AS_IF([test "$with_libc" = yes], [AC_DEFINE([WITH_LIBC], [1], [with libc replacement])]) dnl Packages (virtual) -AS_IF([test "$with_arch_i386" = yes], [AC_DEFINE([WITH_ARCH_X86], [1], [with architecture x86])]) -AS_IF([test "$with_arch_x86_64" = yes], [AC_DEFINE([WITH_ARCH_X86], [1], [with architecture x86])]) +AS_IF([test "$with_arch_i386" = yes], [AC_DEFINE([WITH_ARCH_X86], [1], [with architecture x86])]) +AS_IF([test "$with_arch_x86_64" = yes], [AC_DEFINE([WITH_ARCH_X86], [1], [with architecture x86])]) dnl Additional -AS_IF([test "$enable_debug" = yes], [AC_DEFINE([KERNAUX_DEBUG], [1], [enabled debugging])]) +AS_IF([test "$enable_debug" = yes], [AC_DEFINE([KERNAUX_DEBUG], [1], [enabled debugging])]) @@ -333,6 +338,43 @@ AC_C_INLINE AC_CHECK_HEADER_STDBOOL AC_CHECK_HEADERS([stdarg.h stddef.h stdint.h]) +AM_PATH_PYTHON([3.8],, [:]) + +AC_PATH_PROGS([CPPCHECK], [cppcheck], [:]) + +AC_CACHE_CHECK([for Python YAML], + [libkernaux_cv_shell_pythonyaml_exists], + [libkernaux_cv_shell_pythonyaml_exists=no + PYTHON_YAML=no + if test "$PYTHON" != ':'; then + if test "$($PYTHON -c 'import yaml; print(yaml.__package__)')" = 'yaml'; then + libkernaux_cv_shell_pythonyaml_exists=yes + PYTHON_YAML=yes + fi + fi]) + +AC_CACHE_CHECK([for Python Jinja 2], + [libkernaux_cv_shell_pythonjinja2_exists], + [libkernaux_cv_shell_pythonjinja2_exists=no + PYTHON_JINJA2=no + if test "$PYTHON" != ':'; then + if test "$($PYTHON -c 'import jinja2; print(jinja2.__package__)')" = 'jinja2'; then + libkernaux_cv_shell_pythonjinja2_exists=yes + PYTHON_JINJA2=yes + fi + fi]) + + + +############# +# Test args # +############# + +AS_IF([test "$enable_checks_cppcheck" = yes -a "$CPPCHECK" = ':'], AC_MSG_ERROR([cppcheck is required])) +AS_IF([test "$enable_checks_python" = yes -a "$PYTHON" = ':'], AC_MSG_ERROR([Python is required])) +AS_IF([test "$enable_checks_python" = yes -a "$PYTHON_YAML" != 'yes'], AC_MSG_ERROR([Python YAML is required])) +AS_IF([test "$enable_checks_python" = yes -a "$PYTHON_JINJA2" != 'yes'], AC_MSG_ERROR([Python Jinja 2 is required])) + ###################### diff --git a/tests/Makefile.am b/tests/Makefile.am index 6c15a824..41f3e14f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -86,7 +86,7 @@ endif # test_cmdline_gen # #################### -if ENABLE_TESTS_PYTHON +if ENABLE_CHECKS_PYTHON if WITH_CMDLINE TESTS += test_cmdline_gen test_cmdline_gen_LDADD = $(top_builddir)/libkernaux.la @@ -104,7 +104,7 @@ endif CLEANFILES += test_cmdline_gen.c test_cmdline_gen.c: cmdline_gen.py cmdline_gen.jinja $(top_srcdir)/common/cmdline.yml - python3 cmdline_gen.py + $(PYTHON) cmdline_gen.py ############ # test_elf # @@ -322,7 +322,7 @@ endif # test_printf_fmt_gen # ####################### -if ENABLE_TESTS_PYTHON +if ENABLE_CHECKS_PYTHON if WITH_PRINTF_FMT TESTS += test_printf_fmt_gen test_printf_fmt_gen_LDADD = $(top_builddir)/libkernaux.la @@ -338,13 +338,13 @@ endif CLEANFILES += test_printf_fmt_gen.c test_printf_fmt_gen.c: printf_fmt_gen.py printf_fmt_gen.jinja $(top_srcdir)/common/printf_fmt.yml - python3 printf_fmt_gen.py + $(PYTHON) printf_fmt_gen.py ################### # test_printf_gen # ################### -if ENABLE_TESTS_PYTHON +if ENABLE_CHECKS_PYTHON if WITH_PRINTF TESTS += test_printf_gen test_printf_gen_LDADD = $(top_builddir)/libkernaux.la @@ -361,7 +361,7 @@ endif CLEANFILES += test_printf_gen.c test_printf_gen.c: printf_gen.py printf_gen.jinja $(top_srcdir)/common/printf.yml $(top_srcdir)/common/printf_orig.yml - python3 printf_gen.py + $(PYTHON) printf_gen.py #################### # test_units_human #