summaryrefslogtreecommitdiffstats
path: root/src/ccapi/test/Makefile
blob: 40aad41a509689f2797c220e5793c8ab48c95f99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# run with "make all" to create CCAPI tests in "/tmp/ccapi_test"
# run resulting tests with "sh test_ccapi.sh"

CC = gcc
LIBS = -lkrb5

SRCDIR = src
DSTROOT = /tmp
OBJDIR = $(DSTROOT)/ccapi_intermediates
DSTDIR = $(DSTROOT)/ccapi_test
TESTDIR = $(DSTDIR)/tests

SCRIPT_NAME = test_ccapi.sh

_OBJECTS =      test_ccapi_ccache \
                test_ccapi_check \
                test_ccapi_constants \
                test_ccapi_context \
                test_ccapi_globals \
                test_ccapi_iterators \
                test_ccapi_log \
                test_ccapi_util \
                test_ccapi_v2

OBJECTS = $(patsubst %,$(OBJDIR)/%.o,$(_OBJECTS))

TEST_NAMES =    test_constants \
                test_cc_initialize \
                test_cc_context_release \
                test_cc_context_get_change_time \
                test_cc_context_get_default_ccache_name \
                test_cc_context_open_ccache \
                test_cc_context_open_default_ccache \
                test_cc_context_create_ccache \
                test_cc_context_create_default_ccache \
                test_cc_context_create_new_ccache \
                test_cc_context_new_ccache_iterator \
                test_cc_context_compare \
                test_cc_ccache_release \
                test_cc_ccache_destroy \
                test_cc_ccache_set_default \
                test_cc_ccache_get_credentials_version \
                test_cc_ccache_get_name \
                test_cc_ccache_get_principal \
                test_cc_ccache_set_principal \
                test_cc_ccache_store_credentials \
                test_cc_ccache_remove_credentials \
                test_cc_ccache_new_credentials_iterator \
                test_cc_ccache_get_change_time \
                test_cc_ccache_get_last_default_time \
                test_cc_ccache_move \
                test_cc_ccache_compare \
                test_cc_ccache_get_kdc_time_offset \
                test_cc_ccache_set_kdc_time_offset \
                test_cc_ccache_clear_kdc_time_offset \
                test_cc_ccache_iterator_next \
                test_cc_credentials_iterator_next\
                test_cc_shutdown \
                test_cc_get_change_time \
                test_cc_open \
                test_cc_create \
                test_cc_close \
                test_cc_destroy \
                test_cc_get_cred_version \
                test_cc_get_name \
                test_cc_get_principal \
                test_cc_set_principal \
                test_cc_store \
                test_cc_remove_cred \
                test_cc_seq_fetch_NCs_begin \
                test_cc_seq_fetch_NCs_next \
                test_cc_seq_fetch_creds_begin \
                test_cc_seq_fetch_creds_next \
                test_cc_get_NC_info


TEST_OBJECTS = $(patsubst %,$(OBJDIR)/%.o,$(TEST_NAMES))

all: setup-test-dir simple_lock_test build-base build-tests link-tests copy-script success-message

# compile base files used by all tests
build-base: $(OBJECTS)

# compile each test
build-tests: $(TEST_OBJECTS)

# rule to compile src files
$(OBJDIR)/%.o: %.c
	$(CC) -c -o $@ $<

# Make a build directory
setup-test-dir:
	@echo "Removing old destination directory... $(DSTDIR)"
	if [ -d "$(DSTDIR)" ]; then chmod -R u+w "$(DSTDIR)" && rm -rf "$(DSTDIR)"; fi
	mkdir -p "$(TESTDIR)"
	if [ -d "$(OBJDIR)" ]; then chmod -R u+w "$(OBJDIR)" && rm -rf "$(OBJDIR)"; fi
	mkdir -p "$(OBJDIR)"

link-tests: $(TEST_NAMES)

$(TEST_NAMES): $(TEST_OBJECTS)
	$(CC) -o $(TESTDIR)/$@ $(OBJDIR)/$@.o $(OBJECTS) $(LIBS)

simple_lock_test:
	$(CC) -o $(TESTDIR)/simple_lock_test simple_lock_test.c test_ccapi_log.c $(LIBS)

copy-script:
	cp $(SCRIPT_NAME) $(DSTDIR)/$(SCRIPT_NAME)

success-message:
	@echo
	@echo "CCAPI tests created in $(DSTDIR)"

.PHONY: clean

clean:
	-rm -rf "$(OBJDIR)"