libebgenv_a_SOURCES = \
- tools/bg_utils.c \
+ env/env_api_fat.c \
tools/ebgpart.c \
swupdate-adapter/ebgenv.c
@@ -54,16 +54,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
@@ -78,11 +78,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) bg_setenv$(EXEEXT) \
@@ -194,7 +194,7 @@ bg_printenv: $(bg_setenv) build_tests
build_tests:
@if [ "x$(BUILD_TESTS)" = "x1" ]; then\
- make -C tools/tests;\
+ make -C tools/tests ENV_API=env_api_fat;\
fi
clean-local:
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 07f6610..946ce92 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 d52deaa..1633a72 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
@@ -98,6 +100,9 @@ $(foreach test,$(TEST_TARGETS),$(eval $(call
TEST_TARGET_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};