hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame localedata/tests-mbwc/tsp_common.c

Packit 6c4009
/*
Packit 6c4009
 *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
Packit 6c4009
 *  Main driver
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
Packit 6c4009
#define TST_FUNCTION_CALL(func) _TST_FUNCTION_CALL(func)
Packit 6c4009
#define _TST_FUNCTION_CALL(func) tst ##_## func
Packit 6c4009
Packit 6c4009
#include <stdio.h>
Packit 6c4009
#include <stdlib.h>
Packit 6c4009
#include <string.h>
Packit 6c4009
#include <locale.h>
Packit 6c4009
#include <errno.h>
Packit 6c4009
#include <signal.h>
Packit 6c4009
Packit 6c4009
#include "tst_types.h"
Packit 6c4009
#include "tgn_locdef.h"
Packit 6c4009
Packit 6c4009
Packit 6c4009
int
Packit 6c4009
main (int argc, char *argv[])
Packit 6c4009
{
Packit 6c4009
  int ret;
Packit 6c4009
  int debug;
Packit 6c4009
Packit 6c4009
  debug = argc > 1 ? atoi (argv[1]) : 0;
Packit 6c4009
Packit 6c4009
  if (debug)
Packit 6c4009
    {
Packit 6c4009
      fprintf (stdout, "\nTST_MBWC ===> %s ...\n", argv[0]);
Packit 6c4009
    }
Packit 6c4009
  ret = TST_FUNCTION_CALL (TST_FUNCTION) (stdout, debug);
Packit 6c4009
Packit 6c4009
  return (ret != 0);
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#define	 MAX_RESULT_REC	 132
Packit 6c4009
char result_rec[MAX_RESULT_REC];
Packit 6c4009
Packit 6c4009
Packit 6c4009
int
Packit 6c4009
result (FILE * fp, char res, const char *func, const char *loc, int rec_no,
Packit 6c4009
	int seq_no, int case_no, const char *msg)
Packit 6c4009
{
Packit 6c4009
  if (fp == NULL
Packit 6c4009
      || strlen (func) + strlen (loc) + strlen (msg) + 32 > MAX_RESULT_REC)
Packit 6c4009
    {
Packit 6c4009
      fprintf (stderr,
Packit 6c4009
	       "Warning: result(): can't write the result: %s:%s:%d:%d:%s\n",
Packit 6c4009
	       func, loc, rec_no, case_no, msg);
Packit 6c4009
      return 0;
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  sprintf (result_rec, "%s:%s:%d:%d:%d:%c:%s\n", func, loc, rec_no, seq_no,
Packit 6c4009
	   case_no, res, msg);
Packit 6c4009
Packit 6c4009
  if (fputs (result_rec, fp) == EOF)
Packit 6c4009
    {
Packit 6c4009
      return 0;
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  return 1;
Packit 6c4009
}