* contrib/vmlog/vmlog.c: Use autoconf define WORDS_BIGENDIAN to determine endianess.
[cacao.git] / contrib / vmlog / t / log.c
1 #include "t/prolog.h"
2
3 int main(int argc,char **argv) 
4 {
5         vmlog_log *vml;
6         int i;
7         int r;
8         int fd;
9         struct stat st;
10         int cumlen;
11         void *t1 = (void*)123;
12         char *name;
13         vmlog_thread_log *tlog;
14         vmlog_log_entry logent;
15
16         vml = vmlog_log_new(NULL,1);
17         NOTNULL(vml);
18
19         vmlog_file_open(&(vml->idxfile),"TESTIDX",vmlogTruncateAppend);
20         vmlog_file_open(&(vml->strfile),"TESTSTR",vmlogTruncateAppend);
21
22         tlog = vmlog_get_thread_log(vml,t1);
23         vmlog_file_open(&(tlog->logfile),"TESTLOG1",vmlogTruncateAppend);
24
25         vmlog_log_enter(vml,t1,"foo(II)V",8);
26         name = "bar(Ljava/lang/Object;)Z"; vmlog_log_enter(vml,t1,name,strlen(name));
27         name = "bar(Ljava/lang/Object;)Z"; vmlog_log_leave(vml,t1,name,strlen(name));
28         vmlog_log_leave(vml,t1,"foo(II)V",8);
29
30         vmlog_log_free(vml);
31         vml = NULL;
32
33         fd = open("TESTLOG1",O_RDONLY);
34         TRUE(fd != -1);
35         r = fstat(fd,&st);
36         TRUE(r != -1);
37         IS(st.st_size,4*sizeof(vmlog_log_entry));
38
39         r = read(fd,&logent,sizeof(vmlog_log_entry));
40         TRUE(r == sizeof(vmlog_log_entry));
41         IS(logent.tag,VMLOG_TAG_ENTER);
42         
43         r = read(fd,&logent,sizeof(vmlog_log_entry));
44         TRUE(r == sizeof(vmlog_log_entry));
45         IS(logent.tag,VMLOG_TAG_ENTER);
46         
47         r = read(fd,&logent,sizeof(vmlog_log_entry));
48         TRUE(r == sizeof(vmlog_log_entry));
49         IS(logent.tag,VMLOG_TAG_LEAVE);
50         
51         r = read(fd,&logent,sizeof(vmlog_log_entry));
52         TRUE(r == sizeof(vmlog_log_entry));
53         IS(logent.tag,VMLOG_TAG_LEAVE);
54         
55         close(fd);
56
57         return 0;
58 }
59
60 /* vim: noet ts=8 sw=8
61  */
62
63
64