Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / eventlog / test / elogtest.c
blobde51ad5b36624d726e98f8a83f89e9255efa365d
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
10 #include <afs/param.h>
11 #include <afs/stds.h>
13 #include <windows.h>
14 #include <stddef.h>
15 #include <stdlib.h>
16 #include <stdio.h>
18 #include <WINNT/afsreg.h>
19 #include <WINNT/afsevent.h>
21 int main(int argc, char **argv)
23 HKEY applogKey, afslogKey;
24 long status;
26 /* Determine if registry is (likely to be) configured */
28 status = RegOpenKeyAlt(AFSREG_NULL_KEY, AFSREG_APPLOG_KEY,
29 KEY_READ, 0, &applogKey, NULL);
31 if (status == ERROR_SUCCESS) {
32 status = RegOpenKeyAlt(applogKey, AFSREG_SVR_APPLOG_SUBKEY,
33 KEY_READ, 0, &afslogKey, NULL);
35 if (status == ERROR_SUCCESS) {
36 (void) RegCloseKey(afslogKey);
39 (void) RegCloseKey(applogKey);
42 if (status != ERROR_SUCCESS) {
43 printf("\n%s: expected event source %s not found in registry; "
44 "test not run.\n", argv[0], AFSREG_SVR_APPLOG_SUBKEY);
45 exit(0);
48 /* Log test message w/o any insertion strings */
50 printf("Logging server INFORMATION event (0 insert strings)\n");
51 if (ReportInformationEventAlt(AFSEVT_SVR_TEST_MSG_NOARGS, 0)) {
52 printf("\n%s: logging failed\n", argv[0]);
53 exit(1);
56 printf("Logging server WARNING event (0 insert strings, status 0)\n");
57 if (ReportWarningEventAlt(AFSEVT_SVR_TEST_MSG_NOARGS, 0, 0)) {
58 printf("\n%s: logging failed\n", argv[0]);
59 exit(1);
62 printf("Logging server ERROR event (0 insert strings, status 15)\n");
63 if (ReportErrorEventAlt(AFSEVT_SVR_TEST_MSG_NOARGS, 15, 0)) {
64 printf("\n%s: logging failed\n", argv[0]);
65 exit(1);
68 /* Log test message with two insertion strings */
70 printf("Logging server INFORMATION event (2 insert strings)\n");
71 if (ReportInformationEventAlt(AFSEVT_SVR_TEST_MSG_TWOARGS,
72 "Insert string 1", "Insert String 2", 0)) {
73 printf("\n%s: logging failed\n", argv[0]);
74 exit(1);
77 printf("Logging server WARNING event (2 insert strings, status 0)\n");
78 if (ReportWarningEventAlt(AFSEVT_SVR_TEST_MSG_TWOARGS, 0,
79 "Insert string 1", "Insert String 2", 0)) {
80 printf("\n%s: logging failed\n", argv[0]);
81 exit(1);
84 printf("Logging server ERROR event (2 insert strings, status 15)\n");
85 if (ReportErrorEventAlt(AFSEVT_SVR_TEST_MSG_TWOARGS, 15,
86 "Insert string 1", "Insert String 2", 0)) {
87 printf("\n%s: logging failed\n", argv[0]);
88 exit(1);
91 return 0;