Changeset 8722

Show
Ignore:
Timestamp:
02/02/11 18:00:11 (2 years ago)
Author:
sampson
Message:

Coding Windows tests

Location:
branches/windows-client/src/client/windows/client-test
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/windows-client/src/client/windows/client-test/client-test.c

    r8721 r8722  
    1717 
    1818/* test prototypes */ 
    19 extern int test_test(op_options *options, int fatal); 
     19/* extern int test_test(op_options *options, int fatal); */ 
     20extern int create_dir(op_options *options, int fatal); 
     21extern int create_subdir(op_options *options, int fatal); 
    2022 
    2123typedef struct _list_node 
     
    3436test_operation op_table[] = 
    3537{ 
    36     {"test-test", test_test, FALSE}, 
     38    /*{"test-test", test_test, FALSE}, */ 
     39    {"create-dir", create_dir, TRUE}, 
     40    {"create-subdir", create_subdir, TRUE}, 
    3741    {NULL, NULL, 0} 
    3842}; 
  • branches/windows-client/src/client/windows/client-test/create.c

    r8721 r8722  
    1414} 
    1515 
     16char randchar() 
     17{ 
     18    return rand() % 26 + 'a'; 
     19} 
     20 
    1621int create_dir(op_options *options, int fatal) 
    1722{ 
     
    2429    code = errno; 
    2530 
    26     report_result(options, "create-dir", RESULT_SUCCESS, 0, OPER_EQUAL, errno); 
     31    report_result(options, "create-dir", RESULT_SUCCESS, 0, OPER_EQUAL, code); 
    2732 
    2833    create_dir_cleanup(dir); 
     
    4045int create_subdir(op_options *options, int fatal) 
    4146{ 
    42     int rem_size = MAX_SIZE; 
     47    int rem_size = MAX_SIZE, dir_size, i,  
     48        code = 0; 
     49    char path[MAX_SIZE*2], dir[9]; 
    4350 
    44     rem_size -= strlen(options->root_dir); 
    45  
    46     while (rem_size > 0) 
     51    /* copy root into path */ 
     52    strcpy(path, options->root_dir); 
     53    /* rem_size -= strlen(options->root_dir); */ 
     54    /* add backslash if necessary */ 
     55    if (strlen(options->root_dir) &&  
     56        options->root_dir[strlen(options->root_dir)-1] != '\\') 
    4757    { 
    48  
    49  
     58        strcat(path, "\\"); 
     59        /* rem_size--; */ 
    5060    } 
    5161 
    52      
     62    /* note--root dir is not included in the path size */ 
     63 
     64    while (rem_size > 0 && code == 0) 
     65    { 
     66        /* generate subdir */ 
     67        dir_size = rem_size > 8 ? 8 : rem_size; 
     68        for (i = 0; i < dir_size-1; i++) 
     69            dir[i] = randchar(); 
     70        dir[dir_size-1] = '\\'; 
     71        dir[dir_size] = '\0'; 
     72 
     73        /* append the path */ 
     74        strcat(path, dir); 
     75 
     76        /* create the sub-directory */ 
     77        _mkdir(path); 
     78        code = errno; 
     79 
     80        rem_size -= dir_size; 
     81    } 
     82 
     83    report_result(options, "create-subdir", RESULT_SUCCESS, 0, OPER_EQUAL, code); 
     84 
     85    if (code != 0 && fatal) 
     86        return CODE_FATAL; 
     87 
     88    return 0; 
    5389} 
  • branches/windows-client/src/client/windows/client-test/test-support.c

    r8721 r8722  
    132132 
    133133    /* print to buffer */ 
    134     ret = _snprintf(line, line_size, "%s %s %d %2s %d %s", 
     134    ret = _snprintf(line, line_size, "%s %s %d %s %d %s", 
    135135                    test_name,  
    136136                    (expected_result == RESULT_SUCCESS) ? "EXPECT_SUCCESS" : "EXPECT_FAILURE",