|
Packit |
fd8b60 |
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
Packit |
fd8b60 |
#include <stdio.h>
|
|
Packit |
fd8b60 |
#include <string.h>
|
|
Packit |
fd8b60 |
#include <stdlib.h>
|
|
Packit |
fd8b60 |
#include "com_err.h"
|
|
Packit |
fd8b60 |
#include "et1.h"
|
|
Packit |
fd8b60 |
#include "et2.h"
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
int misc_err, known_err; /* known_err is err in whether or not
|
|
Packit |
fd8b60 |
table is 'known' to library */
|
|
Packit |
fd8b60 |
int fail;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
static void
|
|
Packit |
fd8b60 |
try_one (errcode_t code, int known, int table, int msgno)
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
const char *msg = error_message (code);
|
|
Packit |
fd8b60 |
char buffy[1024];
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
snprintf (buffy, sizeof(buffy), "error table %d message %d", table, msgno);
|
|
Packit |
fd8b60 |
if (0 == strcmp (buffy, msg)) {
|
|
Packit |
fd8b60 |
if (!known) {
|
|
Packit |
fd8b60 |
known_err++;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
return;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
snprintf (buffy, sizeof(buffy), "Unknown code et%d %d", table, msgno);
|
|
Packit |
fd8b60 |
if (!strcmp (buffy, msg)) {
|
|
Packit |
fd8b60 |
if (known)
|
|
Packit |
fd8b60 |
known_err++;
|
|
Packit |
fd8b60 |
return;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
printf ("error code %ld got unrecognized message '%s',\n"
|
|
Packit |
fd8b60 |
"should have been table %d message %d\n",
|
|
Packit |
fd8b60 |
(long) code, msg, table, msgno);
|
|
Packit |
fd8b60 |
misc_err++;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
static void
|
|
Packit |
fd8b60 |
try_table (int table, int known, int lineno,
|
|
Packit |
fd8b60 |
errcode_t c0, errcode_t c1, errcode_t c2)
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
try_one (c0, known, table, 0);
|
|
Packit |
fd8b60 |
try_one (c1, known, table, 1);
|
|
Packit |
fd8b60 |
try_one (c2, known, table, 2);
|
|
Packit |
fd8b60 |
if (misc_err != 0 || known_err != 0) {
|
|
Packit |
fd8b60 |
fail++;
|
|
Packit |
fd8b60 |
if (known_err)
|
|
Packit |
fd8b60 |
printf ("table list error from line %d, table %d\n", lineno,
|
|
Packit |
fd8b60 |
table);
|
|
Packit |
fd8b60 |
if (misc_err)
|
|
Packit |
fd8b60 |
printf ("misc errors from line %d table %d\n", lineno, table);
|
|
Packit |
fd8b60 |
misc_err = known_err = 0;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
static void
|
|
Packit |
fd8b60 |
try_em_1 (int t1_known, int t2_known, int lineno)
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
try_table (1, t1_known, lineno, ET1_M0, ET1_M1, ET1_M2);
|
|
Packit |
fd8b60 |
try_table (2, t2_known, lineno, ET2_M0, ET2_M1, ET2_M2);
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
#define try_em(A,B) try_em_1(A,B,__LINE__)
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
static void *run(/*@unused@*/ void *x)
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
try_em (0, 0);
|
|
Packit |
fd8b60 |
(void) add_error_table (&et_et1_error_table);
|
|
Packit |
fd8b60 |
try_em (1, 0);
|
|
Packit |
fd8b60 |
(void) add_error_table (&et_et2_error_table);
|
|
Packit |
fd8b60 |
try_em (1, 1);
|
|
Packit |
fd8b60 |
(void) remove_error_table (&et_et1_error_table);
|
|
Packit |
fd8b60 |
try_em (0, 1);
|
|
Packit |
fd8b60 |
(void) remove_error_table (&et_et1_error_table);
|
|
Packit |
fd8b60 |
try_em (0, 1);
|
|
Packit |
fd8b60 |
(void) remove_error_table (&et_et2_error_table);
|
|
Packit |
fd8b60 |
try_em (0, 0);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
initialize_et1_error_table ();
|
|
Packit |
fd8b60 |
try_em (1, 0);
|
|
Packit |
fd8b60 |
(void) add_error_table (&et_et1_error_table);
|
|
Packit |
fd8b60 |
try_em (1, 0);
|
|
Packit |
fd8b60 |
(void) remove_error_table (&et_et1_error_table);
|
|
Packit |
fd8b60 |
try_em (1, 0);
|
|
Packit |
fd8b60 |
(void) remove_error_table (&et_et1_error_table);
|
|
Packit |
fd8b60 |
try_em (0, 0);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
initialize_et1_error_table ();
|
|
Packit |
fd8b60 |
try_em (1, 0);
|
|
Packit |
fd8b60 |
(void) add_error_table (&et_et1_error_table);
|
|
Packit |
fd8b60 |
try_em (1, 0);
|
|
Packit |
fd8b60 |
(void) add_error_table (&et_et2_error_table);
|
|
Packit |
fd8b60 |
try_em (1, 1);
|
|
Packit |
fd8b60 |
(void) remove_error_table (&et_et1_error_table);
|
|
Packit |
fd8b60 |
try_em (1, 1);
|
|
Packit |
fd8b60 |
(void) remove_error_table (&et_et1_error_table);
|
|
Packit |
fd8b60 |
try_em (0, 1);
|
|
Packit |
fd8b60 |
(void) remove_error_table (&et_et2_error_table);
|
|
Packit |
fd8b60 |
try_em (0, 0);
|
|
Packit |
fd8b60 |
(void) remove_error_table (&et_et2_error_table);
|
|
Packit |
fd8b60 |
try_em (0, 0);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
(void) add_error_table (&et_et2_error_table);
|
|
Packit |
fd8b60 |
try_em (0, 1);
|
|
Packit |
fd8b60 |
initialize_et2_error_table ();
|
|
Packit |
fd8b60 |
try_em (0, 1);
|
|
Packit |
fd8b60 |
(void) add_error_table (&et_et1_error_table);
|
|
Packit |
fd8b60 |
try_em (1, 1);
|
|
Packit |
fd8b60 |
(void) remove_error_table (&et_et1_error_table);
|
|
Packit |
fd8b60 |
try_em (0, 1);
|
|
Packit |
fd8b60 |
(void) remove_error_table (&et_et2_error_table);
|
|
Packit |
fd8b60 |
try_em (0, 1);
|
|
Packit |
fd8b60 |
(void) remove_error_table (&et_et2_error_table);
|
|
Packit |
fd8b60 |
try_em (0, 0);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
return 0;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
#ifdef TEST_THREADS
|
|
Packit |
fd8b60 |
#include <pthread.h>
|
|
Packit |
fd8b60 |
#endif
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
int main (/*@unused@*/ int argc, /*@unused@*/ char *argv[])
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
#ifdef TEST_THREADS
|
|
Packit |
fd8b60 |
pthread_t t;
|
|
Packit |
fd8b60 |
int err;
|
|
Packit |
fd8b60 |
void *t_retval;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
err = pthread_create(&t, 0, run, 0);
|
|
Packit |
fd8b60 |
if (err) {
|
|
Packit |
fd8b60 |
fprintf(stderr, "pthread_create error: %s\n", strerror(err));
|
|
Packit |
fd8b60 |
exit(1);
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
err = pthread_join(t, &t_retval);
|
|
Packit |
fd8b60 |
if (err) {
|
|
Packit |
fd8b60 |
fprintf(stderr, "pthread_join error: %s\n", strerror(err));
|
|
Packit |
fd8b60 |
exit(1);
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
return fail;
|
|
Packit |
fd8b60 |
#else
|
|
Packit |
fd8b60 |
run(0);
|
|
Packit |
fd8b60 |
return fail;
|
|
Packit |
fd8b60 |
#endif
|
|
Packit |
fd8b60 |
}
|