File: sluid-test.c

package info (click to toggle)
slurm-wlm-contrib 24.11.5-2
  • links: PTS, VCS
  • area: contrib
  • in suites: trixie
  • size: 50,596 kB
  • sloc: ansic: 529,598; exp: 64,795; python: 17,051; sh: 9,411; javascript: 6,528; makefile: 4,030; perl: 3,762; pascal: 131
file content (48 lines) | stat: -rw-r--r-- 1,029 bytes parent folder | download | duplicates (5)
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
#include <errno.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "src/common/log.h"
#include "src/common/sluid.h"
#include "src/common/xmalloc.h"

#include <check.h>

START_TEST(test_sluid)
{
	sluid_t sluid = 0xbc064b4483ea1000, sluid2 = 0;
	char *str = NULL;

	str = sluid2str(sluid);
	ck_assert_msg((!strcmp(str, "sBR1JB8J1YM400")) , "sluid2str(sluid)");
	sluid2 = str2sluid(str);
	ck_assert_msg(sluid == sluid2, "str2sluid(sluid2str(sluid))");
	xfree(str);
}
END_TEST

int main(void)
{
	int number_failed;

	log_options_t log_opts = LOG_OPTS_INITIALIZER;
	log_opts.stderr_level = LOG_LEVEL_DEBUG5;
	log_init("sluid-test", log_opts, 0, NULL);

	Suite *s = suite_create("sluid");
	TCase *tc_core = tcase_create("sluid");

	tcase_add_test(tc_core, test_sluid);

	suite_add_tcase(s, tc_core);

	SRunner *sr = srunner_create(s);

	srunner_run_all(sr, CK_ENV);
	number_failed = srunner_ntests_failed(sr);
	srunner_free(sr);

	return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}