Пример #1
0
    void * tiny_reverse_test(void * arg)
# endif
{
    int i;
    for (i = 0; i < 5; ++i) {
      check_ints(reverse(reverse(ints(1,10))), 1, 10);
    }
    return 0;
}
Пример #2
0
    void * tiny_reverse_test(void * arg)
# endif
{
    int i;
    for (i = 0; i < 5; ++i) {
      check_ints(reverse(reverse(ints(1, TINY_REVERSE_UPPER_VALUE))),
                 1, TINY_REVERSE_UPPER_VALUE);
    }
    return 0;
}
Пример #3
0
static int check_convert_to_bool(const char *value, const bool expected, const int expected_return_code) {
    char *db_str = NULL;
    bool actual;
    int actual_return_code;
    xcb_xrm_database_t *database;

    fprintf(stderr, "== Assert that <%s> is converted to boolean value <%d>\n", value, expected);

    if (value != NULL)
        asprintf(&db_str, "x: %s\n", value);

    database = xcb_xrm_database_from_string(db_str);
    free(db_str);
    actual_return_code = xcb_xrm_resource_get_bool(database, "x", NULL, &actual);
    xcb_xrm_database_free(database);

    return check_ints(expected_return_code, actual_return_code, "Expected <%d>, but found <%d>\n",
            expected_return_code, actual_return_code) ||
        check_ints(expected, actual, "Expected <%d>, but found <%d>\n", expected, actual);
}
Пример #4
0
void check_ints(sexpr list, int low, int up)
{
    if (SEXPR_TO_INT(car(car(list))) != low) {
        GC_printf(
           "List reversal produced incorrect list - collector is broken\n");
        FAIL;
    }
    if (low == up) {
        if (cdr(list) != nil) {
           GC_printf("List too long - collector is broken\n");
           FAIL;
        }
    } else {
        check_ints(cdr(list), low+1, up);
    }
}
Пример #5
0
void check_expected_terms(ecc_context *ctx, const char *test_name,
                          int *expected_terms, unsigned int count)
{

    mock_data *data = (mock_data *)ctx->data;
    unsigned int i, len;
    char buf[10000];

    sprintf(buf, "%s:\nexpected_terms {\n", test_name);
    for (i = 0; i < count; i++) {
        len = strlen(buf);
        sprintf(&buf[len], "%d:\t%d\n", i, expected_terms[i]);
    }
    len = strlen(buf);
    sprintf(&buf[len], "}\n");
    len = strlen(buf);
    ctx->to_string(ctx, &buf[len], sizeof(buf) - len);

    check_unsigned_ints(data->terms, count, buf);
    for (i = 0; i < count; i++) {
        check_ints(data->term[i], expected_terms[i], buf);
    }
}
Пример #6
0
/*
 * Repeatedly reverse lists built out of very different sized cons cells.
 * Check that we didn't lose anything.
 */
void *GC_CALLBACK reverse_test_inner(void *data)
{
    int i;
    sexpr b;
    sexpr c;
    sexpr d;
    sexpr e;
    sexpr *f, *g, *h;

    if (data == 0) {
      /* This stack frame is not guaranteed to be scanned. */
      return GC_call_with_gc_active(reverse_test_inner, (void*)(word)1);
    }

#   if /*defined(MSWIN32) ||*/ defined(MACOS)
      /* Win32S only allows 128K stacks */
#     define BIG 1000
#   elif defined(PCR)
      /* PCR default stack is 100K.  Stack frames are up to 120 bytes. */
#     define BIG 700
#   elif defined(MSWINCE) || defined(RTEMS)
      /* WinCE only allows 64K stacks */
#     define BIG 500
#   elif defined(OSF1)
      /* OSF has limited stack space by default, and large frames. */
#     define BIG 200
#   elif defined(__MACH__) && defined(__ppc64__)
#     define BIG 2500
#   else
#     define BIG 4500
#   endif

    A.dummy = 17;
    a = ints(1, 49);
    b = ints(1, 50);
    c = ints(1, BIG);
    d = uncollectable_ints(1, 100);
    e = uncollectable_ints(1, 1);
    /* Check that realloc updates object descriptors correctly */
    collectable_count++;
    f = (sexpr *)GC_MALLOC(4 * sizeof(sexpr));
    realloc_count++;
    f = (sexpr *)GC_REALLOC((void *)f, 6 * sizeof(sexpr));
    f[5] = ints(1,17);
    collectable_count++;
    g = (sexpr *)GC_MALLOC(513 * sizeof(sexpr));
    realloc_count++;
    g = (sexpr *)GC_REALLOC((void *)g, 800 * sizeof(sexpr));
    g[799] = ints(1,18);
    collectable_count++;
    h = (sexpr *)GC_MALLOC(1025 * sizeof(sexpr));
    realloc_count++;
    h = (sexpr *)GC_REALLOC((void *)h, 2000 * sizeof(sexpr));
#   ifdef GC_GCJ_SUPPORT
      h[1999] = gcj_ints(1,200);
      for (i = 0; i < 51; ++i)
        h[1999] = gcj_reverse(h[1999]);
      /* Leave it as the reveresed list for now. */
#   else
      h[1999] = ints(1,200);
#   endif
    /* Try to force some collections and reuse of small list elements */
    for (i = 0; i < 10; i++) {
      (void)ints(1, BIG);
    }
    /* Superficially test interior pointer recognition on stack */
    c = (sexpr)((char *)c + sizeof(char *));
    d = (sexpr)((char *)d + sizeof(char *));

    GC_FREE((void *)e);

    check_ints(b,1,50);
    check_ints(a,1,49);
    for (i = 0; i < 50; i++) {
        check_ints(b,1,50);
        b = reverse(reverse(b));
    }
    check_ints(b,1,50);
    check_ints(a,1,49);
    for (i = 0; i < 60; i++) {
#       if defined(GC_PTHREADS) || defined(GC_WIN32_THREADS)
            if (i % 10 == 0) fork_a_thread();
#       endif
        /* This maintains the invariant that a always points to a list of */
        /* 49 integers.  Thus this is thread safe without locks,          */
        /* assuming atomic pointer assignments.                           */
        a = reverse(reverse(a));
#       if !defined(AT_END) && !defined(THREADS)
          /* This is not thread safe, since realloc explicitly deallocates */
          if (i & 1) {
            a = (sexpr)GC_REALLOC((void *)a, 500);
          } else {
            a = (sexpr)GC_REALLOC((void *)a, 8200);
          }
#       endif
    }
    check_ints(a,1,49);
    check_ints(b,1,50);

    /* Restore c and d values. */
    c = (sexpr)((char *)c - sizeof(char *));
    d = (sexpr)((char *)d - sizeof(char *));

    check_ints(c,1,BIG);
    check_uncollectable_ints(d, 1, 100);
    check_ints(f[5], 1,17);
    check_ints(g[799], 1,18);
#   ifdef GC_GCJ_SUPPORT
      h[1999] = gcj_reverse(h[1999]);
#   endif
    check_ints(h[1999], 1,200);
#   ifndef THREADS
        a = 0;
#   endif
    *(volatile void **)&b = 0;
    *(volatile void **)&c = 0;
    return 0;
}