Revision 5fafdf24 tests/linux-test.c

b/tests/linux-test.c
1 1
/*
2 2
 *  linux and CPU test
3
 * 
3
 *
4 4
 *  Copyright (c) 2003 Fabrice Bellard
5 5
 *
6 6
 *  This program is free software; you can redistribute it and/or modify
......
58 58
int __chk_error(const char *filename, int line, int ret)
59 59
{
60 60
    if (ret < 0) {
61
        error1(filename, line, "%m (ret=%d, errno=%d)", 
61
        error1(filename, line, "%m (ret=%d, errno=%d)",
62 62
               ret, errno);
63 63
    }
64 64
    return ret;
......
93 93

  
94 94
    if (getcwd(cur_dir, sizeof(cur_dir)) == NULL)
95 95
        error("getcwd");
96
    
96
   
97 97
    chk_error(mkdir(TESTPATH, 0755));
98
    
98
   
99 99
    chk_error(chdir(TESTPATH));
100
    
100
   
101 101
    /* open/read/write/close/readv/writev/lseek */
102 102

  
103 103
    fd = chk_error(open("file1", O_WRONLY | O_TRUNC | O_CREAT, 0644));
......
124 124
        error("read");
125 125
    if (memcmp(buf, buf2, FILE_BUF_SIZE) != 0)
126 126
        error("memcmp");
127
    
127
   
128 128
#define FOFFSET 16
129 129
    ret = chk_error(lseek(fd, FOFFSET, SEEK_SET));
130 130
    if (ret != 16)
......
138 138
        error("readv");
139 139
    if (memcmp(buf + FOFFSET, buf3, FILE_BUF_SIZE - FOFFSET) != 0)
140 140
        error("memcmp");
141
    
141
   
142 142
    chk_error(close(fd));
143 143

  
144 144
    /* access */
......
171 171
    chk_error(ftruncate(fd, 50));
172 172
    chk_error(fstat(fd, &st));
173 173
    chk_error(close(fd));
174
    
174
   
175 175
    if (st.st_size != 50)
176 176
        error("stat size");
177 177
    if (!S_ISREG(st.st_mode))
178 178
        error("stat mode");
179
    
179
   
180 180
    /* symlink/lstat */
181 181
    chk_error(symlink("file2", "file3"));
182 182
    chk_error(lstat("file3", &st));
183 183
    if (!S_ISLNK(st.st_mode))
184 184
        error("stat mode");
185
    
185
   
186 186
    /* getdents */
187 187
    dir = opendir(TESTPATH);
188 188
    if (!dir)
......
241 241
    ti = tv2.tv_sec - tv.tv_sec;
242 242
    if (ti >= 2)
243 243
        error("gettimeofday");
244
    
244
   
245 245
    chk_error(getrusage(RUSAGE_SELF, &rusg1));
246 246
    for(i = 0;i < 10000; i++);
247 247
    chk_error(getrusage(RUSAGE_SELF, &rusg2));
......
272 272
{
273 273
    int len;
274 274
    len = strlen(buf);
275
    if (len < buf_size) 
275
    if (len < buf_size)
276 276
        pstrcpy(buf + len, buf_size - len, s);
277 277
    return buf;
278 278
}
......
327 327
    chk_error(getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &val, &len));
328 328
    if (val != SOCK_STREAM)
329 329
        error("getsockopt");
330
    
330
   
331 331
    pid = chk_error(fork());
332 332
    if (pid == 0) {
333 333
        client_fd = client_socket();
......
419 419
    int pid1, pid2, status1, status2;
420 420

  
421 421
    stack1 = malloc(STACK_SIZE);
422
    pid1 = chk_error(clone(thread1_func, stack1 + STACK_SIZE, 
422
    pid1 = chk_error(clone(thread1_func, stack1 + STACK_SIZE,
423 423
                           CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello1"));
424 424

  
425 425
    stack2 = malloc(STACK_SIZE);
426
    pid2 = chk_error(clone(thread2_func, stack2 + STACK_SIZE, 
426
    pid2 = chk_error(clone(thread2_func, stack2 + STACK_SIZE,
427 427
                           CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello2"));
428 428

  
429 429
    while (waitpid(pid1, &status1, 0) != pid1);
......
465 465
    sigemptyset(&act.sa_mask);
466 466
    act.sa_flags = 0;
467 467
    chk_error(sigaction(SIGALRM, &act, NULL));
468
    
468
   
469 469
    it.it_interval.tv_sec = 0;
470 470
    it.it_interval.tv_usec = 10 * 1000;
471 471
    it.it_value.tv_sec = 0;
......
475 475
    if (oit.it_value.tv_sec != it.it_value.tv_sec ||
476 476
        oit.it_value.tv_usec != it.it_value.tv_usec)
477 477
        error("itimer");
478
    
478
   
479 479
    while (alarm_count < 5) {
480 480
        usleep(10 * 1000);
481 481
    }
......
498 498
    if (setjmp(jmp_env) == 0) {
499 499
        *(uint8_t *)0 = 0;
500 500
    }
501
    
501
   
502 502
    act.sa_handler = SIG_DFL;
503 503
    sigemptyset(&act.sa_mask);
504 504
    act.sa_flags = 0;

Also available in: Unified diff