diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-02-08 00:48:36 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-02-08 01:41:18 -0500 |
commit | 3aadb01e8252557563baaa469cb986fa7ccf11c6 (patch) | |
tree | 61c87019bd8076562c31bfc314d385657dccf58c /libsbutil | |
parent | sb_printf: get z modifier working and fixup tests (diff) | |
download | sandbox-3aadb01e8252557563baaa469cb986fa7ccf11c6.tar.gz sandbox-3aadb01e8252557563baaa469cb986fa7ccf11c6.tar.bz2 sandbox-3aadb01e8252557563baaa469cb986fa7ccf11c6.zip |
tests: get scripts working in sandbox.sh
Make sure we source the local sandbox.{bashrc,conf} and we always make the
helper functions available when testing even if we aren't interactive. Now
we can run `make check` and test the local version of sandbox even when we
are running under another sandbox env.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsbutil')
-rw-r--r-- | libsbutil/Makefile.am | 1 | ||||
-rw-r--r-- | libsbutil/get_sandbox_conf.c | 27 | ||||
-rw-r--r-- | libsbutil/get_sandbox_rc.c | 7 | ||||
-rw-r--r-- | libsbutil/sbutil.h | 1 |
4 files changed, 35 insertions, 1 deletions
diff --git a/libsbutil/Makefile.am b/libsbutil/Makefile.am index 9de8b0a..4a82d62 100644 --- a/libsbutil/Makefile.am +++ b/libsbutil/Makefile.am @@ -14,6 +14,7 @@ noinst_LTLIBRARIES = libsbutil.la libsbutil_la_LDFLAGS = -no-undefined libsbutil_la_SOURCES = \ sbutil.h \ + get_sandbox_conf.c \ get_sandbox_lib.c \ get_sandbox_rc.c \ get_sandbox_log.c \ diff --git a/libsbutil/get_sandbox_conf.c b/libsbutil/get_sandbox_conf.c new file mode 100644 index 0000000..0f2f54b --- /dev/null +++ b/libsbutil/get_sandbox_conf.c @@ -0,0 +1,27 @@ +/* + * get_sandbox_conf.c + * + * Util functions. + * + * Copyright 1999-2008 Gentoo Foundation + * Licensed under the GPL-2 + */ + +#include "headers.h" +#include "sbutil.h" + +/* Where the file exists in our source tree */ +#define LOCAL_SANDBOX_CONF_FILE "/etc/sandbox.conf" + +char *get_sandbox_conf(void) +{ + char *ret = SANDBOX_CONF_FILE; + save_errno(); + if (is_env_on("__SANDBOX_TESTING")) { + char *abs = getenv("abs_top_srcdir"); + ret = xmalloc(strlen(abs) + strlen(LOCAL_SANDBOX_CONF_FILE) + 1); + sprintf(ret, "%s%s", abs, LOCAL_SANDBOX_CONF_FILE); + } + restore_errno(); + return ret; +} diff --git a/libsbutil/get_sandbox_rc.c b/libsbutil/get_sandbox_rc.c index ba383e3..4a94e31 100644 --- a/libsbutil/get_sandbox_rc.c +++ b/libsbutil/get_sandbox_rc.c @@ -16,6 +16,11 @@ void get_sandbox_rc(char *path) { save_errno(); - snprintf(path, SB_PATH_MAX, "%s/%s", SANDBOX_BASHRC_PATH, BASHRC_NAME); + if (is_env_on("__SANDBOX_TESTING")) + snprintf(path, SB_PATH_MAX, "%s/data/%s", + getenv("abs_top_srcdir"), BASHRC_NAME); + else + snprintf(path, SB_PATH_MAX, "%s/%s", + SANDBOX_BASHRC_PATH, BASHRC_NAME); restore_errno(); } diff --git a/libsbutil/sbutil.h b/libsbutil/sbutil.h index 11dbeac..d45ee09 100644 --- a/libsbutil/sbutil.h +++ b/libsbutil/sbutil.h @@ -91,6 +91,7 @@ #define SB_EWARN(_hilight, _args...) sb_efunc(COLOR_YELLOW, _hilight, _args) #define SB_EERROR(_hilight, _args...) sb_efunc(COLOR_RED, _hilight, _args) +char *get_sandbox_conf(void); void get_sandbox_lib(char *path); void get_sandbox_rc(char *path); void get_sandbox_log(char *path); |