void tst_resm_(const char *file, const int lineno, int ttype, const char *arg_fmt, ...) { char tmesg[USERMESG]; EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG); tst_res__(file, lineno, ttype, "%s", tmesg); }
static void tst_brk__(const char *file, const int lineno, int ttype, const char *fname, void (*func)(void), const char *arg_fmt, ...) { pthread_mutex_lock(&tmutex); char tmesg[USERMESG]; int ttype_result = TTYPE_RESULT(ttype); #if DEBUG printf("IN tst_brk__\n"); fflush(stdout); fflush(stdout); #endif EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG); /* * Only FAIL, BROK, CONF, and RETR are supported by tst_brk(). */ if (ttype_result != TFAIL && ttype_result != TBROK && ttype_result != TCONF) { sprintf(Warn_mesg, "%s: Invalid Type: %d. Using TBROK", __func__, ttype_result); tst_print(TCID, 0, TWARN, Warn_mesg); /* Keep TERRNO, TTERRNO, etc. */ ttype = (ttype & ~ttype_result) | TBROK; } tst_res__(file, lineno, ttype, fname, "%s", tmesg); if (tst_brk_entered == 0) { if (ttype_result == TCONF) { tst_res__(file, lineno, ttype, NULL, "Remaining cases not appropriate for " "configuration"); } else if (ttype_result == TBROK) { tst_res__(file, lineno, TBROK, NULL, "Remaining cases broken"); } } /* * If no cleanup function was specified, just return to the caller. * Otherwise call the specified function. */ if (func != NULL) { tst_brk_entered++; (*func) (); tst_brk_entered--; } if (tst_brk_entered == 0) tst_exit(); pthread_mutex_unlock(&tmutex); }
void tst_brkm_(const char *file, const int lineno, int ttype, void (*func)(void), const char *arg_fmt, ...) { char tmesg[USERMESG]; EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG); tst_brk__(file, lineno, ttype, func, "%s", tmesg); /* Shouldn't be reached, but fixes build time warnings about noreturn. */ abort(); }
static void tst_res__(const char *file, const int lineno, int ttype, const char *arg_fmt, ...) { pthread_mutex_lock(&tmutex); char tmesg[USERMESG]; int len = 0; int ttype_result = TTYPE_RESULT(ttype); if (file && (ttype_result != TPASS && ttype_result != TINFO)) len = sprintf(tmesg, "%s:%d: ", file, lineno); EXPAND_VAR_ARGS(tmesg + len, arg_fmt, USERMESG - len); /* * Save the test result type by ORing ttype into the current exit * value (used by tst_exit()). */ T_exitval |= ttype_result; if (ttype_result == TPASS) passed_cnt++; check_env(); /* * Set the test case number and print the results, depending on the * display type. */ if (ttype_result == TWARN || ttype_result == TINFO) { tst_print(TCID, 0, ttype, tmesg); } else { if (tst_count < 0) tst_print(TCID, 0, TWARN, "tst_res(): tst_count < 0 is not valid"); /* * Process each display type. */ switch (T_mode) { case DISCARD: break; case NOPASS: /* filtered by tst_print() */ tst_condense(tst_count + 1, ttype, tmesg); break; default: /* VERBOSE */ tst_print(TCID, tst_count + 1, ttype, tmesg); break; } tst_count++; } pthread_mutex_unlock(&tmutex); }
/* * tst_resm_() - Interface to tst_res(), with no filename. */ void tst_resm_(const char *file, const int lineno, int ttype, const char *arg_fmt, ...) { char tmesg[USERMESG]; #if DEBUG printf("IN tst_resm\n"); fflush(stdout); fflush(stdout); #endif EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG); tst_res__(file, lineno, ttype, NULL, "%s", tmesg); }
/* * tst_brkm_() - Interface to tst_brk(), with no filename. */ void tst_brkm_(const char *file, const int lineno, int ttype, void (*func)(void), const char *arg_fmt, ...) { char tmesg[USERMESG]; #if DEBUG printf("IN tst_brkm_\n"); fflush(stdout); fflush(stdout); #endif EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG); tst_brk__(file, lineno, ttype, NULL, func, "%s", tmesg); /* Shouldn't be reach, but fixes build time warnings about noreturn. */ abort(); }
/* * tst_resm_hexd_() - Interface to tst_res(), with no filename. * Also, dump specified buffer in hex. */ void tst_resm_hexd_(const char *file, const int lineno, int ttype, const void *buf, size_t size, const char *arg_fmt, ...) { pthread_mutex_lock(&tmutex); char tmesg[USERMESG]; #if DEBUG printf("IN tst_resm_hexd_\n"); fflush(stdout); #endif EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG); static const size_t symb_num = 2; /* xx */ static const size_t size_max = 16; size_t offset = strlen(tmesg); char *pmesg = tmesg; if (size > size_max || size == 0 || (offset + size * (symb_num + 1)) >= USERMESG) tst_res__(file, lineno, ttype, NULL, "%s", tmesg); else pmesg += offset; size_t i; for (i = 0; i < size; ++i) { /* add space before byte except first one */ if (pmesg != tmesg) *(pmesg++) = ' '; sprintf(pmesg, "%02x", ((unsigned char *)buf)[i]); pmesg += symb_num; if ((i + 1) % size_max == 0 || i + 1 == size) { tst_res__(file, lineno, ttype, NULL, "%s", tmesg); pmesg = tmesg; } } pthread_mutex_unlock(&tmutex); }
void tst_brkm_(const char *file, const int lineno, int ttype, void (*func)(void), const char *arg_fmt, ...) { char tmesg[USERMESG]; EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG); if (tst_test) { if (func) { tst_brk_(file, lineno, TBROK, "Non-NULL cleanup in newlib!"); } tst_brk_(file, lineno, ttype, "%s", tmesg); } else { tst_brk__(file, lineno, ttype, func, "%s", tmesg); } /* Shouldn't be reached, but fixes build time warnings about noreturn. */ abort(); }
void tst_resm_hexd_(const char *file, const int lineno, int ttype, const void *buf, size_t size, const char *arg_fmt, ...) { char tmesg[USERMESG]; static const size_t symb_num = 2; /* xx */ static const size_t size_max = 16; size_t offset; size_t i; char *pmesg = tmesg; tst_res_func_t res_func; if (tst_test) res_func = tst_res_; else res_func = tst_res__; EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG); offset = strlen(tmesg); if (size > size_max || size == 0 || (offset + size * (symb_num + 1)) >= USERMESG) res_func(file, lineno, ttype, "%s", tmesg); else pmesg += offset; for (i = 0; i < size; ++i) { /* add space before byte except first one */ if (pmesg != tmesg) *(pmesg++) = ' '; sprintf(pmesg, "%02x", ((unsigned char *)buf)[i]); pmesg += symb_num; if ((i + 1) % size_max == 0 || i + 1 == size) { res_func(file, lineno, ttype, "%s", tmesg); pmesg = tmesg; } } }
static void tst_res__(const char *file, const int lineno, int ttype, const char *fname, const char *arg_fmt, ...) { pthread_mutex_lock(&tmutex); char tmesg[USERMESG]; int len = 0; int ttype_result = TTYPE_RESULT(ttype); #if DEBUG printf("IN tst_res__; tst_count = %d\n", tst_count); fflush(stdout); #endif if (file && (ttype_result != TPASS && ttype_result != TINFO)) len = sprintf(tmesg, "%s:%d: ", file, lineno); EXPAND_VAR_ARGS(tmesg + len, arg_fmt, USERMESG - len); /* * Save the test result type by ORing ttype into the current exit * value (used by tst_exit()). */ T_exitval |= ttype_result; /* * Unless T_out has already been set by tst_environ(), make tst_res() * output go to standard output. */ if (T_out == NULL) T_out = stdout; /* * Check TOUTPUT environment variable (if first time) and set T_mode * flag. */ check_env(); if (fname != NULL && access(fname, F_OK) == 0) File = fname; /* * Set the test case number and print the results, depending on the * display type. */ if (ttype_result == TWARN || ttype_result == TINFO) { tst_print(TCID, 0, ttype, tmesg); } else { if (tst_count < 0) tst_print(TCID, 0, TWARN, "tst_res(): tst_count < 0 is not valid"); /* * Process each display type. */ switch (T_mode) { case DISCARD: break; case NOPASS: /* filtered by tst_print() */ tst_condense(tst_count + 1, ttype, tmesg); break; default: /* VERBOSE */ tst_print(TCID, tst_count + 1, ttype, tmesg); break; } tst_count++; } pthread_mutex_unlock(&tmutex); }