Ejemplo n.º 1
0
END_TEST

START_TEST(test_comps_parse5)
{
    FILE *fp;
    char *err_log;
    COMPS_Parsed *parsed;
    COMPS_ListItem *it;
    int ret, i;
    COMPS_List * tmplist;
    COMPS_LoggerEntry* known_errors[2];

    known_errors[0] = comps_log_entry_create("some stray", 0,
                      COMPS_ERR_TEXT_BETWEEN, 6, 4, 0);
    known_errors[1] = comps_log_entry_create("    some stray", 0,
                      COMPS_ERR_TEXT_BETWEEN, 189, 2, 0);

    parsed = comps_parse_parsed_create();
    comps_parse_parsed_init(parsed, "UTF-8", 1);
    fp = fopen("sample_comps_bad3.xml", "r");
    comps_parse_file(parsed, fp);

    fail_if(parsed->log->logger_data->len == 0);
    check_errors(parsed->log, known_errors, 2);

    for (i = 0; i < 2; i++) {
        comps_log_entry_destroy(known_errors[i]);
    }
    comps_parse_parsed_destroy(parsed);
}
Ejemplo n.º 2
0
END_TEST

START_TEST(test_comps_parse3)
{
    FILE *fp;
    char *err_log;
    COMPS_Parsed *parsed;
    COMPS_ListItem *it;
    int ret, i;
    COMPS_List * tmplist;
    COMPS_LoggerEntry* known_errors[3];

    known_errors[0] = comps_log_entry_create("id", 0,
                      COMPS_ERR_ELEM_REQUIRED, 188, 2, 0);
    known_errors[1] = comps_log_entry_create("name", 0,
                      COMPS_ERR_ELEM_REQUIRED, 188, 2, 0);
    known_errors[2] = comps_log_entry_create("description", 0,
                      COMPS_ERR_ELEM_REQUIRED, 188, 2, 0);

    parsed = comps_parse_parsed_create();
    comps_parse_parsed_init(parsed, "UTF-8", 1);
    fp = fopen("sample_comps_bad1.xml", "r");
    comps_parse_file(parsed, fp);

    fail_if(parsed->log->logger_data->len == 0);
    check_errors(parsed->log, known_errors, 3);

    for (i = 0; i < 3; i++) {
        comps_log_entry_destroy(known_errors[i]);
    }
    tmplist = comps_doc_groups(parsed->comps_doc);
    fail_if(((COMPS_DocGroup*)tmplist->first->data)->id != NULL,
            "first group should have NULL id");
    fail_if(((COMPS_DocGroup*)tmplist->first->data)->name != NULL,
            "first group should have NULL id");
    fail_if(((COMPS_DocGroup*)tmplist->first->data)->desc != NULL,
            "first group should have NULL id");
    comps_parse_parsed_destroy(parsed);
}
Ejemplo n.º 3
0
COMPS_LogEntry* __log_entry_x(int code, int n, ...){
    COMPS_LogEntry *entry;
    COMPS_Object *val;
    va_list arg_list;
    
    va_start(arg_list, n);
    entry = comps_log_entry_create();

    entry->args = malloc(sizeof(COMPS_Object*) * n);
    entry->arg_count = n;
    entry->code = code;
    //entry->type = type;
    for (int i=0; i<n; i++) {
        val = va_arg(arg_list, COMPS_Object*);
        entry->args[i] = val;
    }
    va_end(arg_list);
    return entry;
}
Ejemplo n.º 4
0
END_TEST

START_TEST(test_comps_parse4)
{
    FILE *fp;
    char *err_log;
    COMPS_Parsed *parsed;
    COMPS_ListItem *it;
    int ret, i;
    COMPS_List * tmplist;
    COMPS_LoggerEntry* known_errors[15];

    known_errors[0] = comps_log_entry_create("id", 0,
                      COMPS_ERR_NOPARENT, 4, 2, 0);
    known_errors[1] = comps_log_entry_create("packagereq", 0,
                      COMPS_ERR_NOPARENT, 158, 4, 0);
    known_errors[2] = comps_log_entry_create("langonly", 0,
                      COMPS_ERR_ELEM_ALREADYSET, 274, 16, 0);
    known_errors[3] = comps_log_entry_create("groupid", 0,
                      COMPS_ERR_NOPARENT, 588, 4, 0);
    known_errors[4] = comps_log_entry_create("grouplist", 0,
                      COMPS_ERR_NOPARENT, 880, 2, 0);
    known_errors[5] = comps_log_entry_create("groupid", 0,
                      COMPS_ERR_NOPARENT, 881, 4, 0);
    known_errors[6] = comps_log_entry_create("groupid", 0,
                      COMPS_ERR_NOPARENT, 882, 4, 0);
    known_errors[7] = comps_log_entry_create("groupid", 0,
                      COMPS_ERR_NOPARENT, 883, 4, 0);
    known_errors[8] = comps_log_entry_create("groupid", 0,
                      COMPS_ERR_NOPARENT, 884, 4, 0);
    known_errors[9] = comps_log_entry_create("groupid", 0,
                      COMPS_ERR_NOPARENT, 885, 4, 0);
    known_errors[10] = comps_log_entry_create("groupid", 0,
                       COMPS_ERR_NOPARENT, 886, 4, 0);
    known_errors[11] = comps_log_entry_create("groupid", 0,
                       COMPS_ERR_NOPARENT, 887, 4, 0);
    known_errors[12] = comps_log_entry_create("id", 0,
                       COMPS_ERR_NOPARENT, 1210, 2, 0);
    known_errors[13] = comps_log_entry_create("groupid", 0,
                       COMPS_ERR_NOPARENT, 1228, 4, 0);
    known_errors[14] = comps_log_entry_create("optionlist", 0,
                       COMPS_ERR_ELEM_ALREADYSET, 1244, 4, 0);

    parsed = comps_parse_parsed_create();
    comps_parse_parsed_init(parsed, "UTF-8", 1);
    fp = fopen("sample_comps_bad2.xml", "r");
    comps_parse_file(parsed, fp);

    fail_if(parsed->log->logger_data->len == 0);
    check_errors(parsed->log, known_errors, 15);

    for (i = 0; i < 15; i++) {
        comps_log_entry_destroy(known_errors[i]);
    }
    comps_parse_parsed_destroy(parsed);
}