Esempio n. 1
0
static int create_expr_element(ExprElement *pElement, char *pValue, 
    ExprOperation *pOperations)
{
    int type = UNRECOGNIZED_TYPE;

    if (is_number(pValue))
    {
        type = INT;
        pElement->value.intValue = atoi(pValue);
    }
    else
    {
        ExprOperation *pOp = find_operation(pValue, pOperations);

        if (NULL != pOp)
        {
            type = OPERATION;
            pElement->value.pOpValue = pOp;
        }
        else
        {
            pElement->value.pStrValue = pValue;

            if (*pValue == '(')
            {
                type = OPEN_PAREN;
            }
            else if (*pValue == ')')
            {
                type = CLOSE_PAREN;
            }
        }
    }

    pElement->type = type;

    return type;
}
Esempio n. 2
0
int run_tests(global_options *options, list_node *test_list)
{
    int i, ret = 0;
    int all_tests = TRUE;
    list_node *node;
    test_operation *op;

    all_tests = test_list->data == NULL;

    /* call the test options */
    if (all_tests)
    {
        for (i = 0; op_table[i].name; i++)
        {
            /* run the test function */
            ret = op_table[i].function(options, op_table[i].fatal);
            /* this means the test had a technical failure, rather than
               an expected failure (for some tests) */
            if (ret == CODE_FATAL)
            {
                fprintf(stderr, "Test %s: fatal exit\n", op_table[i].name);
                break;
            }
            else if (ret != 0) {
                fprintf(stderr, "Test %s exited with technical error %d\n",
                    op_table[i].name, ret);
                break;
            }
        }
    }
    else 
    {
        /* run in order specified */
        node = test_list;
        while (node)
        {
            op = find_operation((char *) node->data);
            if (op)
            {
                /* run the test function */
                ret = op->function(options, op->fatal);
                if (ret == CODE_FATAL)
                {
                    fprintf(stderr, "Test %s: fatal exit\n", op->name);
                    break;
                }
                else if (ret != 0)
                {
                    fprintf(stderr, "Test %s exited with technical error %d\n",
                        op->name, ret);
                    break;
                }
            }
            else
            {
                fprintf(stderr, "Invalid test: %s\n", (char *) node->data);
            }
            node = node->next;
        }
    }

    free_list(test_list);

    return ret;
}