From: Reichel Andreas <[email protected]> * bg_utils is actually a core API, thus rename it to env_api * move include files to include directory * adapt Makefiles
This patch is a preparation step for a later patch which will simplify the API structure. Signed-off-by: Andreas Reichel <[email protected]> --- Makefile.am | 18 +++++++++--------- tools/bg_utils.c => env/env_api_fat.c | 2 +- {tools => include}/ebgpart.h | 0 tools/bg_utils.h => include/env_api.h | 0 {tools => include}/test-interface.h | 2 +- swupdate-adapter/ebgenv.c | 2 +- tools/bg_setenv.c | 2 +- tools/tests/Makefile | 23 ++++++++++++++--------- tools/tests/test_api.c | 2 +- tools/tests/test_environment.c | 2 +- tools/tests/test_partitions.c | 2 +- 11 files changed, 30 insertions(+), 25 deletions(-) rename tools/bg_utils.c => env/env_api_fat.c (99%) rename {tools => include}/ebgpart.h (100%) rename tools/bg_utils.h => include/env_api.h (100%) rename {tools => include}/test-interface.h (96%) diff --git a/Makefile.am b/Makefile.am index cb8e238..c3908c0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -39,10 +39,10 @@ CLEANFILES = # # Static libraries # -lib_LIBRARIES = libebgenv.a libbg_utils.a +lib_LIBRARIES = libebgenv.a libenv_api.a libebgenv_a_SOURCES = \ - tools/bg_utils.c \ + env/env_api_fat.c \ tools/ebgpart.c \ swupdate-adapter/ebgenv.c @@ -53,16 +53,16 @@ libebgenv_a_CPPFLAGS = \ libebgenv_a_CFLAGS = \ $(AM_CFLAGS) -libbg_utils_a_SOURCES = \ +libenv_api_a_SOURCES = \ tools/ebgpart.c \ - tools/bg_utils.c + env/env_api_fat.c -libbg_utils_a_CFLAGS = \ +libenv_api_a_CFLAGS = \ $(AM_CFLAGS) pkginclude_HEADERS = \ swupdate-adapter/ebgenv.h \ - tools/bg_utils.h + include/env_api.h # # bg_setenv binary @@ -77,11 +77,11 @@ bg_setenv_CFLAGS = \ $(AM_CFLAGS) bg_setenv_LDADD = \ - -lbg_utils \ + -lenv_api \ -lz bg_setenv_DEPENDENCIES = \ - libbg_utils.a + libenv_api.a install-exec-hook: $(LN_S) -f bg_setenv$(EXEEXT) \ @@ -197,7 +197,7 @@ build_tests: .PHONY: check check: - make -C tools/tests run-tests + make -C tools/tests run-tests ENV_API=env_api_fat clean-local: make -C tools/tests clean diff --git a/tools/bg_utils.c b/env/env_api_fat.c similarity index 99% rename from tools/bg_utils.c rename to env/env_api_fat.c index 496e2c8..f282a3f 100644 --- a/tools/bg_utils.c +++ b/env/env_api_fat.c @@ -10,7 +10,7 @@ * the COPYING file in the top-level directory. */ -#include "bg_utils.h" +#include "env_api.h" #include "test-interface.h" const char *tmp_mnt_dir = "/tmp/mnt-XXXXXX"; diff --git a/tools/ebgpart.h b/include/ebgpart.h similarity index 100% rename from tools/ebgpart.h rename to include/ebgpart.h diff --git a/tools/bg_utils.h b/include/env_api.h similarity index 100% rename from tools/bg_utils.h rename to include/env_api.h diff --git a/tools/test-interface.h b/include/test-interface.h similarity index 96% rename from tools/test-interface.h rename to include/test-interface.h index d0bf6d4..cceb1cb 100644 --- a/tools/test-interface.h +++ b/include/test-interface.h @@ -13,7 +13,7 @@ #ifndef __TEST_INTERFACE_H__ #define __TEST_INTERFACE_H__ -#include "bg_utils.h" +#include "env_api.h" bool read_env(CONFIG_PART *part, BG_ENVDATA *env); bool write_env(CONFIG_PART *part, BG_ENVDATA *env); diff --git a/swupdate-adapter/ebgenv.c b/swupdate-adapter/ebgenv.c index 4c767ee..9ac42fc 100644 --- a/swupdate-adapter/ebgenv.c +++ b/swupdate-adapter/ebgenv.c @@ -10,7 +10,7 @@ * the COPYING file in the top-level directory. */ -#include "bg_utils.h" +#include "env_api.h" #include "ebgdefs.h" #include "ebgenv.h" diff --git a/tools/bg_setenv.c b/tools/bg_setenv.c index c006bb6..817d832 100644 --- a/tools/bg_setenv.c +++ b/tools/bg_setenv.c @@ -10,7 +10,7 @@ * the COPYING file in the top-level directory. */ -#include "bg_utils.h" +#include "env_api.h" static char doc[] = "bg_setenv/bg_printenv - Environment tool for the EFI Boot Guard"; diff --git a/tools/tests/Makefile b/tools/tests/Makefile index da12a61..f1fda2e 100644 --- a/tools/tests/Makefile +++ b/tools/tests/Makefile @@ -44,6 +44,8 @@ LIBS = -L../.. \ -lebgenv \ -lz +ENV_API ?= env_api_fat + # Test recipes shall run everytime independent of already built files. # A simple way to achieve this is to depend on files that don't exist # by changing their extension with Makefile's string functions. @@ -51,20 +53,20 @@ LIBS = -L../.. \ # dependency recipes. # All targets' '.target' extensions get removed within the target recipes. # -OBJS_test_partitions = test_partitions.O bg_utils.O ebgpart.O -OBJS_test_environment = test_environment.O bg_utils.O ebgpart.O -OBJS_test_api = test_api.O bg_utils.O ebgenv.O +OBJS_test_partitions = test_partitions.O $(ENV_API).O ebgpart.O +OBJS_test_environment = test_environment.O $(ENV_API).O ebgpart.O +OBJS_test_api = test_api.O $(ENV_API).O ebgenv.O -MOCKOBJS_test_partitions = bg_utils ebgpart -MOCKOBJS_test_environment = bg_utils -MOCKOBJS_test_api = bg_utils +MOCKOBJS_test_partitions = $(ENV_API) ebgpart +MOCKOBJS_test_environment = $(ENV_API) +MOCKOBJS_test_api = $(ENV_API) # Define symbols to be stripped dependent on target and object file name # MOCKOBJS_SYMBOLS_objectname-targetname = symbolname1 symbolname2 ... -MOCKOBJS_SYMBOLS_bg_utils-test_partitions = probe_config_file -MOCKOBJS_SYMBOLS_bg_utils-test_environment = oldenvs configparts fopen fclose fread fwrite feof mount_partition -MOCKOBJS_SYMBOLS_bg_utils-test_api = bgenv_init bgenv_write bgenv_close bgenv_get_latest bgenv_get_by_index bgenv_get_oldest +MOCKOBJS_SYMBOLS_$(ENV_API)-test_partitions = probe_config_file +MOCKOBJS_SYMBOLS_$(ENV_API)-test_environment = oldenvs configparts fopen fclose fread fwrite feof mount_partition +MOCKOBJS_SYMBOLS_$(ENV_API)-test_api = bgenv_init bgenv_write bgenv_close bgenv_get_latest bgenv_get_by_index bgenv_get_oldest MOCKOBJS_SYMBOLS_ebgpart-test_partitions = ped_device_probe_all ped_device_get_next ped_disk_next_partition TEST_TARGETS = test_partitions.target test_environment.target test_api.target @@ -108,6 +110,9 @@ $(foreach test,$(TEST_TARGETS),$(eval $(call TEST_TARGET_RUN_TEMPLATE,$(test)))) %.O: ../%.c $(CC) $(CFLAGS) $(DEFINES) -c $< -o $(@:O=o) +%.O: ../../env/%.c + $(CC) $(CFLAGS) $(DEFINES) -c $< -o $(@:O=o) + %.O: ../../swupdate-adapter/%.c $(CC) $(CFLAGS) $(DEFINES) -c $< -o $(@:O=o) diff --git a/tools/tests/test_api.c b/tools/tests/test_api.c index fb6e658..cca4573 100644 --- a/tools/tests/test_api.c +++ b/tools/tests/test_api.c @@ -18,7 +18,7 @@ #include <cmocka.h> #include <string.h> #include <error.h> -#include "bg_utils.h" +#include "env_api.h" #include "ebgenv.h" static BGENV env = {0}; diff --git a/tools/tests/test_environment.c b/tools/tests/test_environment.c index fe9d50e..63df653 100644 --- a/tools/tests/test_environment.c +++ b/tools/tests/test_environment.c @@ -17,7 +17,7 @@ #include <setjmp.h> #include <cmocka.h> #include <string.h> -#include "bg_utils.h" +#include "env_api.h" #include "test-interface.h" /* Mock functions from libparted */ diff --git a/tools/tests/test_partitions.c b/tools/tests/test_partitions.c index 6781b79..c6865e4 100644 --- a/tools/tests/test_partitions.c +++ b/tools/tests/test_partitions.c @@ -16,7 +16,7 @@ #include <stdbool.h> #include <setjmp.h> #include <cmocka.h> -#include "bg_utils.h" +#include "env_api.h" #include "test-interface.h" static PedDevice ped_devices[32] = {0}; -- 2.14.1 -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/20170905082734.11233-5-andreas.reichel.ext%40siemens.com. For more options, visit https://groups.google.com/d/optout.
