aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python/check-perf-trace.py
blob: 334599c6032c9d2e75c2390790aab23582b41253 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# perf script event handlers, generated by perf script -g python
# (c) 2010, Tom Zanussi <tzanussi@gmail.com>
# Licensed under the terms of the GNU GPL License version 2
#
# This script tests basic functionality such as flag and symbol
# strings, common_xxx() calls back into perf, begin, end, unhandled
# events, etc.  Basically, if this script runs successfully and
# displays expected results, Python scripting support should be ok.

import os
import sys

sys.path.append(os.environ['PERF_EXEC_PATH'] + \
	'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')

from Core import *
from perf_trace_context import *

unhandled = autodict()

def trace_begin():
	print "trace_begin"
	pass

def trace_end():
        print_unhandled()

def irq__softirq_entry(event_name, context, common_cpu,
	common_secs, common_nsecs, common_pid, common_comm,
	common_callchain, vec):
		print_header(event_name, common_cpu, common_secs, common_nsecs,
			common_pid, common_comm)

                print_uncommon(context)

		print "vec=%s\n" % \
		(symbol_str("irq__softirq_entry", "vec", vec)),

def kmem__kmalloc(event_name, context, common_cpu,
	common_secs, common_nsecs, common_pid, common_comm,
	common_callchain, call_site, ptr, bytes_req, bytes_alloc,
	gfp_flags):
		print_header(event_name, common_cpu, common_secs, common_nsecs,
			common_pid, common_comm)

                print_uncommon(context)

		print "call_site=%u, ptr=%u, bytes_req=%u, " \
		"bytes_alloc=%u, gfp_flags=%s\n" % \
		(call_site, ptr, bytes_req, bytes_alloc,

		flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)),

def trace_unhandled(event_name, context, event_fields_dict):
    try:
        unhandled[event_name] += 1
    except TypeError:
        unhandled[event_name] = 1

def print_header(event_name, cpu, secs, nsecs, pid, comm):
	print "%-20s %5u %05u.%09u %8u %-20s " % \
	(event_name, cpu, secs, nsecs, pid, comm),

# print trace fields not included in handler args
def print_uncommon(context):
    print "common_preempt_count=%d, common_flags=%s, common_lock_depth=%d, " \
        % (common_pc(context), trace_flag_str(common_flags(context)), \
               common_lock_depth(context))

def print_unhandled():
    keys = unhandled.keys()
    if not keys:
        return

    print "\nunhandled events:\n\n",

    print "%-40s  %10s\n" % ("event", "count"),
    print "%-40s  %10s\n" % ("----------------------------------------", \
                                 "-----------"),

    for event_name in keys:
	print "%-40s  %10d\n" % (event_name, unhandled[event_name])
' href='#n437'>437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595
/* t-printf.c - Check the estream printf fucntions.
 * Copyright (C) 2013 g10 Code GmbH
 *
 * This file is part of libgpg-error.
 *
 * libgpg-error is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * libgpg-error is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, see <https://www.gnu.org/licenses/>.
 */

/* Note that these tests check against glibc behaviour.  On non glibc
   systems expect non matching return codes in some border cases.  */


#if HAVE_CONFIG_H
# include <config.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <locale.h>

#define PGM "t-printf"

#include "t-common.h"


static char *one_test_buf1;
static int   one_test_rc1;




/* Read all data from STREAM into a new malloced buffer and return
 * that buffer.  The buffer is always 0 terminated.  Either returns a
 * string or dies.  The stream will be trunctaed to zero. */
static char *
stream_to_string (gpgrt_stream_t stream)
{
#define NCHUNK 1024
  char *buffer;
  size_t bufsize, buflen;
  size_t nread;

  gpgrt_rewind (stream);

  buffer = NULL;
  buflen = bufsize = 0;
  do
    {
      bufsize += NCHUNK;
      buffer = realloc (buffer, bufsize+1);
      if (!buffer)
        die ("malloc failed at line %d\n", __LINE__);

      nread = gpgrt_fread (buffer + buflen, 1, NCHUNK, stream);
      if (nread < NCHUNK && gpgrt_ferror (stream))
        die ("fread failed at line %d: %s\n", __LINE__, strerror (errno));
      buflen += nread;
    }
  while (nread == NCHUNK);
  buffer[nread] = 0;

  if (strlen (buffer) != buflen)
    fail ("stream_to_string detected an embedded nul");

  gpgrt_ftruncate (stream, 0);
  return buffer;
#undef NCHUNK
}



static void
one_test_x0 (const char *format, ...)
{
  va_list arg_ptr;

  show ("format: ->%s<-\n", format);

  errno = ENOENT; /* For the "%m" test.  */
  va_start (arg_ptr, format);
#ifdef HAVE_VASPRINTF
  one_test_rc1 = vasprintf (&one_test_buf1, format, arg_ptr);
#else
  one_test_rc1 = -1;
#endif
  va_end (arg_ptr);
  if (one_test_rc1 == -1)
    {
      fail ("   sys: errno=%d (%s)\n", errno, strerror (errno));
      one_test_buf1 = NULL;
    }
  else
    show ("   sys: ->%s<-\n", one_test_buf1);
}

static void
one_test_x1 (const char *format, ...)
{
  int rc2;
  va_list arg_ptr;
  char *buf2;

  errno = ENOENT;
  va_start (arg_ptr, format);
  rc2 = gpgrt_vasprintf (&buf2, format, arg_ptr);
  va_end (arg_ptr);
  if (rc2 == -1)
    {
      fail ("   our: errno=%d (%s)\n", errno, strerror (errno));
    }
  else
    show ("   our: ->%s<-\n", buf2);

  if (one_test_rc1 != -1 && rc2 != -1 && strcmp (one_test_buf1, buf2))
    {
      fail ("error: output does not match\n"
            "format: ->%s<-\n   sys: ->%s<-\n   our: ->%s<-\n",
            format, one_test_buf1, buf2);
    }
  else if ( one_test_rc1 != rc2 )
    {
      fail ("error: return codes are different: sys_rc=%d our_rc=%d\n",
            one_test_rc1, rc2);
    }

  free (buf2);
}

static void
one_test_x2 (const char *format, ...)
{
  va_list arg_ptr;
  char *buf2;

  /* Test once more using the bsprintf variant.  */
  errno = ENOENT;
  va_start (arg_ptr, format);
  buf2 = gpgrt_vbsprintf (format, arg_ptr);
  va_end (arg_ptr);
  if (!buf2)
    {
      fail ("   our(2): errno=%d (%s)\n", errno, strerror (errno));
    }
  else if (verbose)
    show ("   our: ->%s<-\n", buf2);

  if (one_test_rc1 != -1 && buf2 && strcmp (one_test_buf1, buf2))
    {
      fail ("error: output does not match\n"
            "format(2): ->%s<-\n   sys: ->%s<-\n   our: ->%s<-\n",
            format, one_test_buf1, buf2);
    }
  es_free (buf2);

  free (one_test_buf1);
  one_test_buf1 = NULL;
}


#define one_test_0(a)                              \
  one_test_x0 (a);                                 \
  one_test_x1 (a);                                 \
  one_test_x2 (a)
#define one_test_1(a, b)                           \
  one_test_x0 (a, b);                              \
  one_test_x1 (a, b);                              \
  one_test_x2 (a, b)
#define one_test_2(a, b, c)                        \
  one_test_x0 (a, b, c);                           \
  one_test_x1 (a, b, c);                           \
  one_test_x2 (a, b, c)
#define one_test_3(a, b, c, d)                     \
  one_test_x0 (a, b, c, d);                        \
  one_test_x1 (a, b, c, d);                        \
  one_test_x2 (a, b, c, d)

static void
run_tests (void)
{
#ifndef HAVE_VASPRINTF
  /* We do not have a system vasprintf.  */
  show ("run-tests: disabled due to missing vasprintf.\n");
#else /*HAVE_VASPRINTF */

  /*one_test ("%d %% %'d", 17, 19681977);*/

  one_test_2 ("%d %% %d", 17, 768114563);
  one_test_2 ("%d %% %d", 17, -768114563);

  /* Checking thousands is not easy because it depends on the locale.  */
  /* one_test_1 ("%'d", 768114563); */

  one_test_1 ("%d", 17);
  one_test_1 ("%4d", 17);
  one_test_1 ("%40d", 17);
  one_test_1 ("%-d", 17);
  one_test_1 ("%-4d", 17);
  one_test_1 ("%-140d", 17);
  one_test_1 ("%d", -17);
  one_test_1 ("%4d", -17);
  one_test_1 ("%40d", -17);
  one_test_1 ("%-d", -17);
  one_test_1 ("%-4d", -17);
  one_test_1 ("%-40d", -17);

  one_test_1 ("%+4d", 17);
  one_test_1 ("%+4d", -17);
  one_test_1 ("%-+4d", 17);
  one_test_1 ("%-+4d", -17);
  one_test_1 ("% 4d", 17);
  one_test_1 ("% 4d", -17);
  one_test_1 ("%- +4d", 17);
  one_test_1 ("%- +4d", -17);

  one_test_1 ("%.4d", 17);
  one_test_1 ("%.0d", 17);
  one_test_1 ("%.0d", 0);
  one_test_1 ("%.4d", -17);
  one_test_1 ("%.0d", -17);
  one_test_1 ("%6.4d", 17);
  one_test_1 ("%6.4d", -17);
  one_test_1 ("%6.0d", 0);
  one_test_1 ("%4.6d", 17);
  one_test_1 ("%4.6d", -17);

  one_test_1 ("% 4.6d", 17);
  one_test_1 ("% 6.0d", 0);

  one_test_1 ("%.4d", 17);
  one_test_1 ("%04d", 17);
  one_test_1 ("%.4d", -17);
  one_test_1 ("%04d", -17);
  one_test_1 ("%0.d", 0);

  one_test_2 ("%*d", 7, 42);
  one_test_2 ("%*d", -7, 42);
  one_test_2 ("%.*d", 7, 42);
  one_test_2 ("%.*d", -7, 42);
  one_test_3 ("%*.*d", 10, 7, 42);
  one_test_3 ("%*.*d", 10, -7, 42);
  one_test_3 ("%*.*d", -10, 7, 42);
  one_test_3 ("%*.*d", -10, -7, 42);

  one_test_2 ("%*x", 7, 42);
  one_test_2 ("%*x", -7, 42);
  one_test_2 ("%.*x", 7, 42);
  one_test_2 ("%.*x", -7, 42);
  one_test_3 ("%*.*x", 10, 7, 42);
  one_test_3 ("%*.*x", 10, -7, 42);
  one_test_3 ("%*.*x", -10, 7, 42);
  one_test_3 ("%*.*x", -10, -7, 42);
  one_test_2 ("%#*x", 7, 42);
  one_test_2 ("%#*x", -7, 42);
  one_test_2 ("%#.*x", 7, 42);
  one_test_2 ("%#.*x", -7, 42);
  one_test_3 ("%#*.*x", 10, 7, 42);
  one_test_3 ("%#*.*x", 10, -7, 42);
  one_test_3 ("%#*.*x", -10, 7, 42);
  one_test_3 ("%#*.*x", -10, -7, 42);

  one_test_2 ("%*X", 7, 42);
  one_test_2 ("%*X", -7, 42);
  one_test_2 ("%.*X", 7, 42);
  one_test_2 ("%.*X", -7, 42);
  one_test_3 ("%*.*X", 10, 7, 42);
  one_test_3 ("%*.*X", 10, -7, 42);
  one_test_3 ("%*.*X", -10, 7, 42);
  one_test_3 ("%*.*X", -10, -7, 42);
  one_test_2 ("%#*X", 7, 42);
  one_test_2 ("%#*X", -7, 42);
  one_test_2 ("%#.*X", 7, 42);
  one_test_2 ("%#.*X", -7, 42);
  one_test_3 ("%#*.*X", 10, 7, 42);
  one_test_3 ("%#*.*X", 10, -7, 42);
  one_test_3 ("%#*.*X", -10, 7, 42);
  one_test_3 ("%#*.*X", -10, -7, 42);

  one_test_2 ("%*o", 7, 42);
  one_test_2 ("%*o", -7, 42);
  one_test_2 ("%.*o", 7, 42);
  one_test_2 ("%.*o", -7, 42);
  one_test_3 ("%*.*o", 10, 7, 42);
  one_test_3 ("%*.*o", 10, -7, 42);
  one_test_3 ("%*.*o", -10, 7, 42);
  one_test_3 ("%*.*o", -10, -7, 42);
  one_test_2 ("%#*o", 7, 42);
  one_test_2 ("%#*o", -7, 42);
  one_test_2 ("%#.*o", 7, 42);
  one_test_2 ("%#.*o", -7, 42);
  one_test_3 ("%#*.*o", 10, 7, 42);
  one_test_3 ("%#*.*o", 10, -7, 42);
  one_test_3 ("%#*.*o", -10, 7, 42);
  one_test_3 ("%#*.*o", -10, -7, 42);

  one_test_1 ("%s", "the quick brown fox jumps over the lazy dogs back");
  one_test_1 ("%.0s", "the quick brown fox jumps over the lazy dogs back");
  one_test_1 ("%.10s", "the quick brown fox jumps over the lazy dogs back");
  one_test_1 ("%.48s", "the quick brown fox jumps over the lazy dogs back");
  one_test_1 ("%.49s", "the quick brown fox jumps over the lazy dogs back");
  one_test_1 ("%.50s", "the quick brown fox jumps over the lazy dogs back");
  one_test_1 ("%.51s", "the quick brown fox jumps over the lazy dogs back");
  one_test_1 ("%48s", "the quick brown fox jumps over the lazy dogs back");
  one_test_1 ("%49s", "the quick brown fox jumps over the lazy dogs back");
  one_test_1 ("%50s", "the quick brown fox jumps over the lazy dogs back");
  one_test_1 ("%51s", "the quick brown fox jumps over the lazy dogs back");
  one_test_1 ("%-51s", "the quick brown fox jumps over the lazy dogs back");

  one_test_1 ("/%s=", "CN");

  one_test_1 ("%f", 3.1415926535);
  one_test_1 ("%f", -3.1415926535);
  one_test_1 ("%.10f", 3.1415926535);
  one_test_1 ("%.2f", 3.1415926535);
  one_test_1 ("%.1f", 3.1415926535);
  one_test_1 ("%.0f", 3.1415926535);
  one_test_1 ("%.20f", 3.1415926535);
  one_test_1 ("%10.10f", 3.1415926535);
  one_test_1 ("%10.2f", 3.1415926535);
  one_test_1 ("%10.1f", 3.1415926535);
  one_test_1 ("%10.0f", 3.1415926535);
  one_test_1 ("%30.20f", 3.1415926535);
  one_test_1 ("%10.10f", -3.1415926535);
  one_test_1 ("%10.2f", -3.1415926535);
  one_test_1 ("%10.1f", -3.1415926535);
  one_test_1 ("%10.0f", -3.1415926535);
  one_test_1 ("%30.20f", -3.1415926535);

  one_test_1 ("%-10f", 3.1415926535);
  one_test_1 ("%-10.10f", 3.1415926535);
  one_test_1 ("%-10.2f", 3.1415926535);
  one_test_1 ("%-10.1f", 3.1415926535);
  one_test_1 ("%-10.0f", 3.1415926535);
  one_test_1 ("%-30.20f", 3.1415926535);
  one_test_1 ("%-10f", -3.1415926535);
  one_test_1 ("%-10.10f", -3.1415926535);
  one_test_1 ("%-10.2f", -3.1415926535);
  one_test_1 ("%-10.1f", -3.1415926535);
  one_test_1 ("%-10.0f", -3.1415926535);
  one_test_1 ("%-30.20f", -3.1415926535);

  one_test_1 ("%#.0f",  3.1415926535);
  one_test_1 ("%#10.0f",  3.1415926535);
  one_test_1 ("%#10.0f", -3.1415926535);
  one_test_1 ("%-#10.0f",  3.1415926535);
  one_test_1 ("%-#10.0f", -3.1415926535);

  one_test_1 ("%e", 3.1415926535);
  one_test_1 ("%g", 3.1415926535);

  one_test_1 ("%a", 1.0);
  one_test_1 ("%a", -1.0);
  one_test_1 ("%a", 3.1415926535);

#ifdef HAVE_LONG_DOUBLE
  one_test_1 ("%La", (long double)1.0);
  one_test_1 ("%La", (long double)-1.0);
  one_test_1 ("%La", (long double)3.1415926535);
#endif

#ifdef __GLIBC__
  /* "%m" is a glibc extension so this _test_ will only work on such a
     system.  */
  one_test_0 ("%m");
  one_test_1 ("%d=%m", 17);
  one_test_2 ("%2$d:%m:%1$d", 42, 17);
#endif /*__GLIBC__*/

#endif /*HAVE_VASPRINTF */
}

static void
check_snprintf (void)
{
  char buffer[20];
  int rc, rc2;
  size_t tmplen, blen, blen2;

  rc = gpgrt_snprintf (buffer, 0, "%*s", 18, "");
  if (rc != 18)
    printf ("rc=%d\n", rc );
  rc = gpgrt_snprintf (buffer, sizeof buffer, "%*s", 18, "");
  if (rc != 18)
    printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer));
  rc = gpgrt_snprintf (buffer, sizeof buffer, "%*s", 19, "");
  if (rc != 19)
    printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer));
  rc = gpgrt_snprintf (buffer, sizeof buffer, "%*s", 20, "");
  if (rc != 20)
    printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer));
  rc = gpgrt_snprintf (buffer, sizeof buffer, "%*s", 21, "");
  if (rc != 21)
    printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer));

  for (tmplen = 0; tmplen <= sizeof buffer; tmplen++)
    {
      rc = gpgrt_snprintf (buffer, tmplen, "%04d%02d%02dT%02d%02d%02d",
                             1998, 9, 7, 16, 56, 05);
      blen = strlen (buffer);
      rc2 = snprintf (buffer, tmplen, "%04d%02d%02dT%02d%02d%02d",
                     1998, 9, 7, 16, 56, 05);
      blen2 = strlen (buffer);
      if (rc != rc2 || blen != blen2)
        printf ("snprintf test with len %u gives %d instead of %d (%u,%u)\n",
                (unsigned int)tmplen, rc, rc2,
                (unsigned int)blen, (unsigned int)blen2);
    }
}


struct sfstate_s
{
  char *last_result;
};

static char *
string_filter (const char *string, int no, void *opaque)
{
  struct sfstate_s *state = opaque;

  free (state->last_result);
  if (no == -1)
    {
      state->last_result = NULL;
      return NULL;
    }
  if (no == 3)
    state->last_result = NULL;
  else
    state->last_result = strdup (string? string : "[==>Niente<==]");

  return state->last_result;
}


static void
check_fprintf_sf (void)
{
  volatile char *null_ptr = NULL; /* Avoid compiler warning.  */
  struct sfstate_s sfstate = {NULL};
  gpgrt_stream_t stream;
  const char *expect;
  char *result;

  stream = gpgrt_fopenmem (0, "w+b");
  if (!stream)
    die ("fopenmem failed at line %d\n", __LINE__);

  gpgrt_fprintf_sf (stream, string_filter, &sfstate,
                    "%s a=%d b=%s c=%d d=%.8s null=%s\n",
                    null_ptr, 1, "foo\x01 bar", 2,
                    "a longer string", null_ptr);
  expect = "[==>Niente<==] a=1 b=foo\x01 bar c=2 d=a longer null=(null)\n";
  result = stream_to_string (stream);
  if (strcmp (result, expect))
    {
      show ("expect: '%s'\n", expect);
      show ("result: '%s'\n", result);
      fail ("fprintf_sf failed at %d\n", __LINE__);
    }
  free (result);

  gpgrt_fprintf_sf (stream, string_filter, &sfstate,
                    "a=%d b=%s c=%d d=%.8s e=%s\n",
                    1, "foo\n bar", 2, null_ptr, "");
  expect = "a=1 b=foo\n bar c=2 d=[==>Nien e=\n";
  result = stream_to_string (stream);
  if (strcmp (result, expect))
    {
      show ("expect: '%s'\n", expect);
      show ("result: '%s'\n", result);
      fail ("fprintf_sf failed at %d\n", __LINE__);
    }
  free (result);

  gpgrt_fprintf_sf (stream, string_filter, &sfstate,
                    "a=%x b=%b c=%X",
                    19410909u, 19410909u, 19410909u);
  expect = "a=1282fdd b=1001010000010111111011101 c=1282FDD";
  result = stream_to_string (stream);
  if (strcmp (result, expect))
    {
      show ("expect: '%s'\n", expect);
      show ("result: '%s'\n", result);
      fail ("fprintf_sf failed at %d\n", __LINE__);
    }
  free (result);

  gpgrt_fprintf_sf (stream, string_filter, &sfstate,
                    "a=%#x b=%#b c=%#X",
                    19420130u, 19420130u, 19420130u);
  expect = "a=0x12853e2 b=0b1001010000101001111100010 c=0X12853E2";
  result = stream_to_string (stream);
  if (strcmp (result, expect))
    {
      show ("expect: '%s'\n", expect);
      show ("result: '%s'\n", result);
      fail ("fprintf_sf failed at %d\n", __LINE__);
    }
  free (result);

  gpgrt_fclose (stream);
}

static void
check_fwrite (void)
{
  gpgrt_stream_t stream;
  const char *expect;
  char *result;

  stream = gpgrt_fopenmem (0, "w+b");
  if (!stream)
    die ("fopenmem failed at line %d\n", __LINE__);

  gpgrt_fwrite ("Has the dog Buddha-nature or not?", 1, 33, stream);
  expect = "Has the dog Buddha-nature or not?";
  result = stream_to_string (stream);
  if (strcmp (result, expect))
    {
      show ("expect: '%s'\n", expect);
      show ("result: '%s'\n", result);
      fail ("fprintf_sf failed at %d\n", __LINE__);
    }
  free (result);
  gpgrt_fclose (stream);
}


int
main (int argc, char **argv)
{
  int last_argc = -1;

  if (argc)
    {
      argc--; argv++;
    }
  while (argc && last_argc != argc )
    {
      last_argc = argc;
      if (!strcmp (*argv, "--help"))
        {
          puts (
"usage: ./" PGM " [options]\n"
"\n"
"Options:\n"
"  --verbose      Show what is going on\n"
"  --debug        Flyswatter\n"
);
          exit (0);
        }
      if (!strcmp (*argv, "--verbose"))
        {
          verbose = 1;
          argc--; argv++;
        }
      else if (!strcmp (*argv, "--debug"))
        {
          verbose = debug = 1;
          argc--; argv++;
        }
    }

  setlocale (LC_NUMERIC, "");
  if (!gpg_error_check_version (GPG_ERROR_VERSION))
    {
      die ("gpg_error_check_version returned an error");
      errorcount++;
    }

  run_tests ();
  check_snprintf ();
  check_fprintf_sf ();
  check_fwrite ();

#ifdef __GLIBC__
  return !!errorcount;
#else
  return 0;
#endif
}