Skip to content
Snippets Groups Projects
Commit 6cb3d7db authored by Petri Latvala's avatar Petri Latvala
Browse files

runner: Unit tests for the runner


TODO: Unit tests for the results.json file contents.

v2:
 - Avoid writing the nul character to mock files
 - Properly set up tmpdirs

v3:
 - Restore the resume-related changes that were lost in rebase

v4:
 - Better teardown for temporary directories
 - Build with autotools

Signed-off-by: default avatarPetri Latvala <petri.latvala@intel.com>
Reviewed-by: default avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 18c1e752
No related merge requests found
......@@ -421,6 +421,7 @@ AC_CONFIG_FILES([
assembler/intel-gen4asm.pc
overlay/Makefile
runner/Makefile
runner/testdata/Makefile
])
AC_CONFIG_FILES([tools/intel_aubdump], [chmod +x tools/intel_aubdump])
......
igt_runner
igt_resume
igt_results
runner_test
if BUILD_RUNNER
SUBDIRS = testdata
runnerlib = librunner.la
noinst_LTLIBRARIES = $(runnerlib)
librunner_la_SOURCES = \
......@@ -28,4 +30,14 @@ AM_CFLAGS = $(JSONC_CFLAGS) \
-I$(srcdir)/../lib \
-D_GNU_SOURCE
TESTS = runner_test
check_PROGRAMS = runner_test
runner_test_SOURCES = runner_tests.c
runner_test_CFLAGS = -DTESTDATA_DIRECTORY=\"$(abs_builddir)/testdata\" \
-I$(top_srcdir)/include/drm-uapi \
$(DRM_CFLAGS) $(CAIRO_CFLAGS) $(LIBUDEV_CFLAGS) \
-I$(srcdir)/.. \
-I$(srcdir)/../lib \
-D_GNU_SOURCE
endif
......@@ -9,6 +9,7 @@ runnerlib_sources = [ 'settings.c',
runner_sources = [ 'runner.c' ]
resume_sources = [ 'resume.c' ]
results_sources = [ 'results.c' ]
runner_test_sources = [ 'runner_tests.c' ]
if _build_runner and jsonc.found()
subdir('testdata')
......@@ -35,6 +36,13 @@ if _build_runner and jsonc.found()
install_dir : bindir,
dependencies : igt_deps)
runner_test = executable('runner_test', runner_test_sources,
c_args : '-DTESTDATA_DIRECTORY="@0@"'.format(testdata_dir),
link_with : runnerlib,
install : false,
dependencies : igt_deps)
test('runner', runner_test)
build_info += 'Build test runner: Yes'
else
build_info += 'Build test runner: No'
......
This diff is collapsed.
testdata_progs = no-subtests skippers successtest
noinst_PROGRAMS = $(testdata_progs)
test-list.txt: Makefile
@echo TESTLIST > $@
@echo ${testdata_progs} >> $@
@echo END TESTLIST >> $@
noinst_DATA = test-list.txt
all-local: .gitignore
.gitignore: Makefile.am
@echo "$(testdata_progs) test-list.txt /.gitignore" | sed 's/\s\+/\n/g' | sort > $@
CLEANFILES = test-list.txt .gitignore
AM_CFLAGS = $(CWARNFLAGS) -Wno-unused-result $(DEBUG_CFLAGS) \
-I$(top_srcdir)/include/drm-uapi \
-I$(srcdir)/../.. \
-I$(srcdir)/../../lib \
$(DRM_CFLAGS) $(CAIRO_CFLAGS) $(LIBUDEV_CFLAGS) \
-D_GNU_SOURCE
LDADD = $(top_builddir)/lib/libintel_tools.la
testdata_progs = [ 'successtest',
'no-subtests',
'skippers',
]
testdata_executables = []
foreach prog : testdata_progs
testdata_executables += executable(prog, prog + '.c',
dependencies : igt_deps,
install : false)
endforeach
testdata_list = custom_target('testdata_testlist',
output : 'test-list.txt',
command : [ gen_testlist, '@OUTPUT@', testdata_progs ],
build_by_default : true)
testdata_dir = meson.current_build_dir()
#include "igt.h"
igt_simple_main
{
}
#include "igt.h"
igt_main
{
igt_fixture {
igt_require_f(false, "Skipping from fixture\n");
}
igt_subtest("skip-one")
igt_debug("Should be skipped\n");
igt_subtest("skip-two")
igt_debug("Should be skipped\n");
}
#include "igt.h"
igt_main
{
igt_subtest("first-subtest")
igt_debug("Running first subtest\n");
igt_subtest("second-subtest")
igt_debug("Running second subtest\n");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment