File: test.c

package info (click to toggle)
fxt 0.3.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,128 kB
  • sloc: sh: 9,719; ansic: 8,139; perl: 3,284; asm: 598; makefile: 226
file content (97 lines) | stat: -rw-r--r-- 2,877 bytes parent folder | download | duplicates (3)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
 *  Copyright (C) 2016-2017 Universite de Bordeaux
 *
 * This program is free software ; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation ; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY ; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with the program ; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#define CONFIG_FUT
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <windows.h>
#else
#include <pthread.h>
#endif
#include <fut.h>
#include <stdlib.h>

#define BUFFER_SIZE (1<<20)

long myid(void)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
	return (long) GetCurrentThreadId();
#else
	return (long) pthread_self();
#endif
}

int main(void) {
	fprintf(stderr,"setting filename\n");
	fut_set_filename("temp");
	fprintf(stderr,"setting flush\n");
	enable_fut_flush();
	fprintf(stderr,"setting up\n");
	if (fut_setup(BUFFER_SIZE, 0xffff, myid()) < 0)
	{
		perror("fut_setup");
		exit(EXIT_FAILURE);
	}
	fprintf(stderr,"setting key\n");
	if (fut_keychange(FUT_ENABLE, 0x7fffff, myid()) < 0)
	{
		perror("fut_keychange");
		exit(EXIT_FAILURE);
	}
	fprintf(stderr,"setting filename again\n");
	fut_set_filename("temp2");
	fprintf(stderr,"running probes\n");
	FUT_PROBE1(0x1, 0x101, 1234);
	FUT_PROBE2(0x1, 0x102, 1234, 1234);
	FUT_PROBE3(0x1, 0x103, 1234, 1234, 1234);
	FUT_PROBE4(0x1, 0x104, 1234, 1234, 1234, 1234);
	FUT_PROBE5(0x1, 0x105, 1234, 1234, 1234, 1234, 1234);
	FUT_PROBE6(0x1, 0x106, 1234, 1234, 1234, 1234, 1234, 1234);
	FUT_PROBE7(0x1, 0x107, 1234, 1234, 1234, 1234, 1234, 1234, 1234);

	fprintf(stderr,"running string probe\n");
	FUT_PROBESTR(0x1, 0x200, "foof");
	fprintf(stderr,"ending up\n");
	if (fut_endup("temp2") < 0)
	{
		perror("fut_endup");
		exit(EXIT_FAILURE);
	}
	fprintf(stderr,"done\n");
	if (fut_done() < 0)
	{
		perror("fut_done");
		exit(EXIT_FAILURE);
	}
	fprintf(stderr,"ok\n");
	if (system("./fxt_print -f temp2 > fxt_print.log") != 0) {
		fprintf(stderr,"error fxt_print");
		exit(EXIT_FAILURE);
	}
	if (system("grep \"4294967295	             107(7)	         unknown code 107	4d2	4d2	4d2	4d2	4d2	4d2	4d2\" fxt_print.log") != 0) {
		system("cat fxt_print.log");
		fprintf(stderr,"error fxt_print string output");
		exit(EXIT_FAILURE);
	}
	if (system("grep \"4294967295	             200(1)	         unknown code 200	666f6f66\" fxt_print.log") != 0) {
		system("cat fxt_print.log");
		fprintf(stderr,"error fxt_print string output");
		exit(EXIT_FAILURE);
	}
	exit(EXIT_SUCCESS);
}