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
|
/*
* Copyright (C) 2016-2026 Red Hat, Inc. All rights reserved.
*
* Authors: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+
*/
#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "libknet.h"
#include "test-common.h"
static void test(void)
{
const char *res;
printf("Testing knet_log_get_subsystem_name normal lookup\n");
res = knet_log_get_subsystem_name(KNET_SUB_NSSCRYPTO);
if (strcmp(res, "nsscrypto")) {
printf("knet_log_get_subsystem_name failed to get correct log subsystem name. got: %s expected: nsscrypto\n",
res);
exit(FAIL);
}
printf("Testing knet_log_get_subsystem_name bad lookup (within boundaries)\n");
res = knet_log_get_subsystem_name(KNET_SUB_UNKNOWN - 1);
if (strcmp(res, "unknown")) {
printf("knet_log_get_subsystem_name failed to get correct log subsystem name. got: %s expected: common\n",
res);
exit(FAIL);
}
printf("Testing knet_log_get_subsystem_name bad lookup (outside boundaries)\n");
res = knet_log_get_subsystem_name(KNET_MAX_SUBSYSTEMS);
if (strcmp(res, "unknown")) {
printf("knet_log_get_subsystem_name failed to get correct log subsystem name. got: %s expected: common\n",
res);
exit(FAIL);
}
}
int main(int argc, char *argv[])
{
test();
return PASS;
}
|