mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-10 13:29:58 -05:00
tests: modify usergroup-test to use 'check' test framework
This commit is contained in:
parent
3db18c27d2
commit
5f2a25b252
2 changed files with 30 additions and 17 deletions
|
|
@ -521,8 +521,8 @@ alsa_time_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
|
||||||
|
|
||||||
usergroup_test_SOURCES = tests/usergroup-test.c
|
usergroup_test_SOURCES = tests/usergroup-test.c
|
||||||
usergroup_test_LDADD = $(AM_LDADD) libpulsecore-@PA_MAJORMINOR@.la libpulse.la libpulsecommon-@PA_MAJORMINOR@.la
|
usergroup_test_LDADD = $(AM_LDADD) libpulsecore-@PA_MAJORMINOR@.la libpulse.la libpulsecommon-@PA_MAJORMINOR@.la
|
||||||
usergroup_test_CFLAGS = $(AM_CFLAGS)
|
usergroup_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
|
||||||
usergroup_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
|
usergroup_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
|
||||||
|
|
||||||
connect_stress_SOURCES = tests/connect-stress.c
|
connect_stress_SOURCES = tests/connect-stress.c
|
||||||
connect_stress_LDADD = $(AM_LDADD) libpulse.la
|
connect_stress_LDADD = $(AM_LDADD) libpulse.la
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <check.h>
|
||||||
|
|
||||||
#include <pulsecore/usergroup.h>
|
#include <pulsecore/usergroup.h>
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
|
|
||||||
|
|
@ -117,40 +119,51 @@ static int compare_passwd(const struct passwd *a, const struct passwd *b) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
START_TEST (usergroup_test) {
|
||||||
struct group *gr;
|
struct group *gr;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
int err;
|
|
||||||
struct group *reference_group = NULL;
|
struct group *reference_group = NULL;
|
||||||
struct passwd *reference_passwd = NULL;
|
struct passwd *reference_passwd = NULL;
|
||||||
|
|
||||||
err = load_reference_structs(&reference_group, &reference_passwd);
|
fail_if(load_reference_structs(&reference_group, &reference_passwd));
|
||||||
if (err)
|
|
||||||
return 77;
|
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
gr = pa_getgrgid_malloc(reference_group->gr_gid);
|
gr = pa_getgrgid_malloc(reference_group->gr_gid);
|
||||||
if (compare_group(reference_group, gr))
|
fail_if(compare_group(reference_group, gr));
|
||||||
return 1;
|
|
||||||
pa_getgrgid_free(gr);
|
pa_getgrgid_free(gr);
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
gr = pa_getgrnam_malloc(reference_group->gr_name);
|
gr = pa_getgrnam_malloc(reference_group->gr_name);
|
||||||
if (compare_group(reference_group, gr))
|
fail_if(compare_group(reference_group, gr));
|
||||||
return 1;
|
|
||||||
pa_getgrnam_free(gr);
|
pa_getgrnam_free(gr);
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
pw = pa_getpwuid_malloc(reference_passwd->pw_uid);
|
pw = pa_getpwuid_malloc(reference_passwd->pw_uid);
|
||||||
if (compare_passwd(reference_passwd, pw))
|
fail_if(compare_passwd(reference_passwd, pw));
|
||||||
return 1;
|
|
||||||
pa_getpwuid_free(pw);
|
pa_getpwuid_free(pw);
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
pw = pa_getpwnam_malloc(reference_passwd->pw_name);
|
pw = pa_getpwnam_malloc(reference_passwd->pw_name);
|
||||||
if (compare_passwd(reference_passwd, pw))
|
fail_if(compare_passwd(reference_passwd, pw));
|
||||||
return 1;
|
|
||||||
pa_getpwnam_free(pw);
|
pa_getpwnam_free(pw);
|
||||||
|
}
|
||||||
return 0;
|
END_TEST
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
int failed = 0;
|
||||||
|
Suite *s;
|
||||||
|
TCase *tc;
|
||||||
|
SRunner *sr;
|
||||||
|
|
||||||
|
s = suite_create("Usergroup");
|
||||||
|
tc = tcase_create("usergroup");
|
||||||
|
tcase_add_test(tc, usergroup_test);
|
||||||
|
suite_add_tcase(s, tc);
|
||||||
|
|
||||||
|
sr = srunner_create(s);
|
||||||
|
srunner_run_all(sr, CK_NORMAL);
|
||||||
|
failed = srunner_ntests_failed(sr);
|
||||||
|
srunner_free(sr);
|
||||||
|
|
||||||
|
return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue