tests: Move common code to its own directory

Move code for faking up an OpenAFS configuration directory into its
own "common" directory, as it's going to be of use to more tests than
just those in auth.

Change-Id: I9c80dd66763e222deca98bc7744ff317111c6ed8
Reviewed-on: http://gerrit.openafs.org/4806
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Simon Wilkinson 2011-05-30 17:47:35 +01:00 committed by Derrick Brashear
parent a9c8d2b895
commit 799b3373ec
10 changed files with 33 additions and 19 deletions

View File

@ -947,6 +947,7 @@ distclean: clean
tests/tap/Makefile \
tests/auth/Makefile \
tests/cmd/Makefile \
tests/common/Makefile \
tests/util/Makefile \
src/helper-splint.sh
if test -d doc/man-pages ; then \

View File

@ -245,6 +245,7 @@ src/helper-splint.sh \
tests/Makefile \
tests/auth/Makefile \
tests/cmd/Makefile \
tests/common/Makefile \
tests/rpctestlib/Makefile \
tests/tap/Makefile \
tests/util/Makefile,

View File

@ -9,7 +9,7 @@ include @TOP_OBJDIR@/src/config/Makefile.pthread
MODULE_CFLAGS = -DSOURCE='"$(abs_top_srcdir)/tests"' \
-DBUILD='"$(abs_top_builddir)/tests"'
SUBDIRS = tap auth util cmd
SUBDIRS = tap common auth util cmd
all: runtests
@for A in $(SUBDIRS); do cd $$A && $(MAKE) $@ && cd .. || exit 1; done

View File

@ -6,7 +6,7 @@ include @TOP_OBJDIR@/src/config/Makefile.pthread
TESTS = authcon-t superuser-t keys-t
MODULE_CFLAGS=-I$(srcdir)/..
MODULE_CFLAGS=-I$(srcdir)/.. -I$(srcdir)/../common/
all check test tests: $(TESTS)
@ -17,17 +17,17 @@ MODULE_LIBS = ../tap/libtap.a \
$(LIB_rfc3961) $(LIB_roken) -lafsutil\
$(XLIBS)
authcon-t: authcon-t.o common.o
$(AFS_LDRULE) authcon-t.o common.o \
authcon-t: authcon-t.o ../common/config.o
$(AFS_LDRULE) authcon-t.o ../common/config.o \
$(MODULE_LIBS)
superuser-t: superuser-t.o common.o test.cs.o test.ss.o test.xdr.o
$(AFS_LDRULE) superuser-t.o common.o \
superuser-t: superuser-t.o ../common/config.o test.cs.o test.ss.o test.xdr.o
$(AFS_LDRULE) superuser-t.o ../common/config.o \
test.cs.o test.ss.o test.xdr.o \
$(MODULE_LIBS)
keys-t: keys-t.o common.o
$(AFS_LDRULE) keys-t.o common.o $(MODULE_LIBS)
keys-t: keys-t.o ../common/config.o
$(AFS_LDRULE) keys-t.o ../common/config.o $(MODULE_LIBS)
writekeyfile: writekeyfile.o
$(AFS_LDRULE) writekeyfile.o $(MODULE_LIBS)
@ -44,7 +44,7 @@ test.xdr.c: test.xg
test.h: test.xg
$(RXGEN) -A -x -h -o $@ $(srcdir)/test.xg
superuser-t.o: test.h common.h
superuser-t.o: test.h
clean:
rm -f *.o *.cs.c *.ss.c *.xdr.c test.h \

View File

@ -51,7 +51,7 @@ main(int argc, char **argv)
struct afsconf_typedKey *key;
plan(9);
dirname = buildTestConfig();
dirname = afstest_BuildTestConfig();
dir = afsconf_Open(dirname);
if (dir == NULL) {

View File

@ -110,7 +110,7 @@ int main(int argc, char **argv)
/* Create a temporary afs configuration directory */
dirname = buildTestConfig();
dirname = afstest_BuildTestConfig();
if (asprintf(&keyfile, "%s/KeyFile", dirname) == -1)
goto out;
@ -557,12 +557,12 @@ int main(int argc, char **argv)
afsconf_Close(dir);
unlinkTestConfig(dirname);
afstest_UnlinkTestConfig(dirname);
free(dirname);
free(keyfile);
/* Start a new test configuration */
dirname = buildTestConfig();
dirname = afstest_BuildTestConfig();
dir = afsconf_Open(dirname);
ok(dir != NULL, "Sucessfully opened brand new config directory");
if (dir == NULL)
@ -583,7 +583,7 @@ int main(int argc, char **argv)
" ... with the right key");
out:
unlinkTestConfig(dirname);
afstest_UnlinkTestConfig(dirname);
return 0;
}

View File

@ -457,7 +457,7 @@ int main(int argc, char **argv)
/* Otherwise, do the basic configuration, then start the client and
* server */
dirname = buildTestConfig();
dirname = afstest_BuildTestConfig();
dir = afsconf_Open(dirname);
if (dir == NULL) {

12
tests/common/Makefile.in Normal file
View File

@ -0,0 +1,12 @@
srcdir=@srcdir@
abs_top_builddir=@abs_top_builddir@
include @TOP_OBJDIR@/src/config/Makefile.config
include @TOP_OBJDIR@/src/config/Makefile.pthread
MODULE_CFLAGS=-I$(srcdir)/..
all check test tests: config.o
clean:
rm -f *.o

View File

@ -22,5 +22,5 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
extern char *buildTestConfig(void);
extern void unlinkTestConfig(char *);
extern char *afstest_BuildTestConfig(void);
extern void afstest_UnlinkTestConfig(char *);

View File

@ -68,7 +68,7 @@ unlinkConfigFile(char *dirname, char *filename) {
*/
char *
buildTestConfig(void) {
afstest_BuildTestConfig(void) {
char *dir = NULL;
FILE *file;
@ -102,7 +102,7 @@ fail:
*/
void
unlinkTestConfig(char *dir)
afstest_UnlinkTestConfig(char *dir)
{
unlinkConfigFile(dir, "KeyFile");
unlinkConfigFile(dir, "CellServDB");