-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_util.c
63 lines (53 loc) · 1.73 KB
/
test_util.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "util.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <fcntl.h>
#define LINE_LENGTH 128
int main(int argc, char **argv){
char *fileName = "./testFiles/testutil.txt";
char line[LINE_LENGTH];
int i, ret, fd;
printf("===\nRunning Test Set for util.c.\n===\n\n");
///// Open file, attribute it to log->fd
ret = open(fileName, O_RDWR | O_APPEND | O_CREAT,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (ret == -1)
printf("Could not open file: %s\n", fileName);
else
fd = ret;
ret = readLine(fd, line, LINE_LENGTH);
printf("ret = %d\n", ret);
printf("line = %s\n", line);
ret = readLine(fd, line, LINE_LENGTH);
printf("ret = %d\n", ret);
printf("line = %s\n", line);
ret = readLine(fd, line, LINE_LENGTH);
printf("ret = %d\n", ret);
printf("line = %s\n", line);
ret = readLine(fd, line, LINE_LENGTH);
printf("ret = %d\n", ret);
printf("line = %s\n", line);
ret = readLine(fd, line, LINE_LENGTH);
printf("ret = %d\n", ret);
printf("line = %s\n", line);
ret = readLine(fd, line, LINE_LENGTH);
printf("ret = %d\n", ret);
printf("line = %s\n", line);
ret = readLine(fd, line, LINE_LENGTH);
printf("ret = %d\n", ret);
printf("line = %s\n", line);
ret = readLine(fd, line, LINE_LENGTH);
printf("ret = %d\n", ret);
printf("line = %s\n", line);
ret = readLine(fd, line, LINE_LENGTH);
printf("ret = %d\n", ret);
printf("line = %s\n", line);
ret = readLine(fd, line, LINE_LENGTH);
printf("ret = %d\n", ret);
printf("line = %s\n", line);
printf("Some Strerror testing.\n");
for (i = 0 ; i >= -10 ; i--)
printf("%s\n", strError(i));
return 0;
}