Working CUnit test but still meh autoconf

This commit is contained in:
Bandie 2018-05-11 04:03:19 +02:00
parent 28ce22b131
commit b7cb4c0b81
Signed by: Bandie
GPG Key ID: C1E133BC65A822DD
4 changed files with 19 additions and 9 deletions

View File

@ -4,7 +4,7 @@ AC_INIT(
[https://github.com/pampanic/pam_panic/issues],
[pam_panic])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([-Wall])
AM_INIT_AUTOMAKE([-Wall subdir-objects])
AC_PREREQ([2.69])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADER([src/config.h])

View File

@ -8,10 +8,8 @@ LICENSE : GNU-GPLv3
#include <stdint.h>
#include <unistd.h>
#ifndef TEST
#include <security/pam_modules.h>
#include <security/pam_ext.h>
#endif
#include <syslog.h>
#include "pam_panic_reject.h"

View File

@ -1,3 +1,4 @@
CFLAGS += -DTEST
bin_PROGRAMS = test
test_SOURCES = test.h ../src/pam_panic/pam_panic_authdevice.c ../src/pam_panic/pam_panic_reject.c test.c
test_LDFLAGS = -lpam -lcunit
@ -5,4 +6,3 @@ test_LDFLAGS = -lpam -lcunit
all:
@printf "Running test...\n"
./test
@printf "OK!\n"

View File

@ -4,7 +4,7 @@
#include "../src/pam_panic/pam_panic_authdevice.h"
#include "../src/pam_panic/pam_panic_reject.h"
#include <CUnit/Basic.h>
#include <CUnit/TestRun.h>
#define STATE_GOOD 0
#define STATE_BAD 99
@ -36,6 +36,7 @@ void test_authDeviceGood(void) {
fclose(f);
int ret = authDevice(NULL, gU, bU, NULL, 0, 0, 0);
printf("%d\n", ret);
CU_ASSERT_EQUAL(ret, STATE_GOOD);
unlink(gU);
}
@ -81,7 +82,7 @@ void test_rejectNA(void) {
int main(void) {
// no stdout buffering
setbuf(stdout, NULL);
//setbuf(stdout, NULL);
// init CUnit test registry
CU_pSuite pSuiteDevice = NULL;
@ -112,6 +113,17 @@ int main(void) {
return CU_get_error();
}
return 0;
/* Run all tests */
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
int fail = CU_get_number_of_failures();
CU_cleanup_registry();
if(fail)
return 1;
return CU_get_error();
}