Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cmocka framework, test head (#67)
* add cmocka framework * separate test makefile * separate test makefile * add some head tests, fix bug in head_matches_name_desc_partial * test wrappers, more head tests * test asserts, iwyu * more head tests * more head tests * remove unnecessary head tests
- Loading branch information
1 parent
d21ef54
commit 52ec8a9
Showing
14 changed files
with
375 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ clang | |
|
||
-Iinc | ||
-Ipro | ||
-Itst | ||
|
||
-D_GNU_SOURCE | ||
-DVERSION="DUMMY" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,7 @@ | |
pro/*.h | ||
pro/*.c | ||
|
||
way-displays | ||
example-client | ||
test | ||
|
||
tags | ||
|
||
.copy | ||
|
||
cfg.dev.yaml | ||
/way-displays | ||
/example-client | ||
/tst-* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
include GNUmakefile | ||
|
||
CPPFLAGS += -Itst | ||
|
||
PKGS_TST = cmocka | ||
CFLAGS += $(foreach p,$(PKGS_TST),$(shell pkg-config --cflags $(p))) | ||
CXXFLAGS += $(foreach p,$(PKGS_TST),$(shell pkg-config --cflags $(p))) | ||
LDLIBS += $(foreach p,$(PKGS_TST),$(shell pkg-config --libs $(p))) | ||
|
||
TST_H = $(wildcard tst/*.h) | ||
TST_C = $(wildcard tst/*.c) | ||
TST_CXX = $(wildcard tst/*.cpp) | ||
TST_O = $(TST_C:.c=.o) $(TST_CXX:.cpp=.o) | ||
TST_E = $(TST_O:tst/%.o=%) | ||
|
||
$(TST_O): $(TST_H) $(SRC_O) config.mk GNUmakefile tst/GNUmakefile | ||
|
||
tst-head: tst/tst-head.o $(filter-out src/main.o,$(SRC_O)) $(PRO_O) | ||
$(CXX) -o $(@) $(^) $(LDFLAGS) $(LDLIBS) -Wl,--wrap=mode_dpi,--wrap=mode_user_mode,--wrap=log_info,--wrap=log_warn | ||
|
||
tst-layout: tst/tst-layout.o | ||
$(CXX) -o $(@) $(^) $(LDFLAGS) $(LDLIBS) | ||
|
||
tst-all: $(TST_E) | ||
@for e in $(^); do echo; echo $$e; ./$$e; done | ||
|
||
tst-clean: | ||
rm -f $(TST_O) $(TST_E) | ||
|
||
tst-iwyu: CC = $(IWYU) -Xiwyu --check_also="inc/*h" | ||
tst-iwyu: CXX = $(IWYU) -Xiwyu --check_also="inc/marshalling.h" | ||
tst-iwyu: clean $(TST_O) | ||
IWYU = /usr/bin/include-what-you-use -Xiwyu --no_fwd_decls -Xiwyu --no_comments -Xiwyu --verbose=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef ASSERTS_H | ||
#define ASSERTS_H | ||
|
||
#include <cmocka.h> | ||
|
||
#include "wayland-util.h" | ||
|
||
static void _assert_wl_fixed_t_equal_double(wl_fixed_t a, double b, | ||
const char * const file, const int line) { | ||
|
||
if (a != wl_fixed_from_double(b)) { | ||
cmocka_print_error("%g != %g\n", wl_fixed_to_double(a), b); | ||
_fail(file, line); | ||
} | ||
} | ||
#define assert_wl_fixed_t_equal_double(a, b) _assert_wl_fixed_t_equal_double(a, b, __FILE__, __LINE__) | ||
|
||
#endif // ASSERTS_H | ||
|
Oops, something went wrong.