Commit Graph

3 Commits

Author SHA1 Message Date
William Lallemand
0b22c8e0e0 TESTS: unit-tests: store sh -x in a result file
Store `sh -e -x` of the test in a result file. This file is deleted upon
success, but can be consulted if the test fails
2025-03-06 21:22:38 +01:00
William Lallemand
7fdc4160b2 TESTS: change the output of run-unittests.sh
- "check" is run with sh -e so it will stop at the first error
- output of "check" is not shown anymore
- add a line with the name of the failed test
2025-03-06 17:53:53 +01:00
William Lallemand
1e7478bb4e TESTS: add a unit test runner in the Makefile
`make unit-tests` would run shell scripts from tests/unit/

The run-unittests.sh script will look for any .sh in tests/unit/ and
will call it twice:

- first with the 'check' argument in order to decide if we should skip
  the test or not
- second to run the check

A simple test could be written this way:

	#!/bin/sh

	check() {
	       ${HAPROXY_PROGRAM} -cc 'feature(OPENSSL)'
	       command -v socat
	}

	run() {
		 ${HAPROXY_PROGRAM} -dI -f ${ROOTDIR}/examples/quick-test.cfg -c
	}

	case "$1" in
	       "check")
	               check
	       ;;
	       "run")
	               run
	       ;;
	esac

The tests *MUST* be written in POSIX shell in order to be portable, and
any special commands should be tested with `command -v` before using it.

Tests are run with `sh -e` so everything must be tested.
2025-03-03 12:43:32 +01:00