Example #1
0
static void inspect_after(struct list *shape)
{
    /* we should get exactly one node at the top level and one nested list */
    ___SL_ASSERT(shape);
    ___SL_ASSERT(shape->next == NULL);
    ___SL_ASSERT(shape->slist != NULL);

    /* the nested list should be zero terminated (iterator back by one node) */
    struct node *pos;
    for (pos = shape->slist; pos->next; pos = pos->next);
    ___SL_ASSERT(!pos->next);
}
Example #2
0
int main()
{
    int i = ___sl_get_nondet_int();
    if (i < -1) {
        ___sl_plot("less-than-minus-one", &i);
        ___SL_ASSERT(i < -1);
    }
    else if (-1 < i) {
        ___sl_plot("more-than-minus-one", &i);
        ___SL_ASSERT(-1 < i);
    }
    else {
        ___sl_plot("equal-to-minus-one", &i);
        ___SL_ASSERT(-1 == i);
    }

    return 0;
}
Example #3
0
static void inspect_before(struct list *shape)
{
    /* we should get a list of sub-lists of length exactly one */
    ___SL_ASSERT(shape);

    for (; shape->next; shape = shape->next) {
        ___SL_ASSERT(shape);
        ___SL_ASSERT(shape->next);
        ___SL_ASSERT(shape->slist);
        ___SL_ASSERT(shape->slist->next == NULL);
    }

    /* check the last node separately to make the exercising more fun */
    ___SL_ASSERT(shape);
    ___SL_ASSERT(shape->next == NULL);
    ___SL_ASSERT(shape->slist);
    ___SL_ASSERT(shape->slist->next == NULL);
}
Example #4
0
int main()
{
    int i = ___sl_get_nondet_int();
    if (i < 0)
        ___sl_plot("less-than-zero", &i);
    else if (0 < i)
        ___sl_plot("more-than-zero", &i);
    else {
        ___sl_plot("equal-to-zero", &i);
        ___SL_ASSERT(!i);
    }

    return 0;
}
Example #5
0
int main()
{
    char *ptr;

    switch (___sl_get_nondet_int()) {
        case 0:
            // SAFE (without alignment)
            ptr = do_memset(
                    /* size_to_alloc    */ N,
                    /* addr_alignment   */ 1,
                    /* shift_beg        */ 0,
                    /* shift_end        */ 0);
            break;

        case 1:
            // SAFE
            ptr = do_memset(
                    /* size_to_alloc    */ N,
                    /* addr_alignment   */ sizeof(double),
                    /* shift_beg        */ 0,
                    /* shift_end        */ 0);
            break;

        case 2:
            // SAFE, but will trigger assertion failure afterwards
            ptr = do_memset(
                    /* size_to_alloc    */ N,
                    /* addr_alignment   */ sizeof(double),
                    /* shift_beg        */ 1,
                    /* shift_end        */ 0);
            break;

        case 3:
            // SAFE, but will trigger assertion failure afterwards
            ptr = do_memset(
                    /* size_to_alloc    */ N,
                    /* addr_alignment   */ sizeof(double),
                    /* shift_beg        */ 0,
                    /* shift_end        */ -1);
            break;

        case 4:
            // above the allocated area by 1B (without alignment)
            ptr = do_memset(
                    /* size_to_alloc    */ N,
                    /* addr_alignment   */ 1,
                    /* shift_beg        */ -1,
                    /* shift_end        */ -1);
            break;

        case 5:
            // byond the allocated area by 1B (without alignment)
            ptr = do_memset(
                    /* size_to_alloc    */ N,
                    /* addr_alignment   */ 1,
                    /* shift_beg        */ 0,
                    /* shift_end        */ 1);
            break;

        case 6:
            // above the allocated area by 1B
            ptr = do_memset(
                    /* size_to_alloc    */ N,
                    /* addr_alignment   */ sizeof(double),
                    /* shift_beg        */ -1,
                    /* shift_end        */ -1);
            break;

        case 7:
            // byond the allocated area by 1B
            ptr = do_memset(
                    /* size_to_alloc    */ N,
                    /* addr_alignment   */ sizeof(double),
                    /* shift_beg        */ 0,
                    /* shift_end        */ 1);
            break;

        default:
            return 1;
    }

    // NOTE: this triggers some false positives if join is enabled
    ___SL_ASSERT(!ptr[sizeof(double) - 1]);
    ___SL_ASSERT(!ptr[N - sizeof(double)]);
    ___sl_plot("end-of-main-reached", &ptr);

    return 0;
}