source: test/test-errors.c @ e111394

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since e111394 was 148338c, checked in by Shane Alcock <salcock@…>, 10 years ago
  • Disable the WRONLY test, seeing as the new IO system now always uses WRONLY when opening output files
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 * This file is part of libtrace
3 *
4 * Copyright (c) 2004 The University of Waikato, Hamilton, New Zealand.
5 * Authors: Daniel Lawson
6 *          Perry Lorier
7 *         
8 * All rights reserved.
9 *
10 * This code has been developed by the University of Waikato WAND
11 * research group. For further information please see http://www.wand.net.nz/
12 *
13 * libtrace is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * libtrace is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with libtrace; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 *
27 * $Id: test-rtclient.c,v 1.2 2006/02/27 03:41:12 perry Exp $
28 *
29 */
30#include <libtrace.h>
31#include <assert.h>
32
33/* If you don't specify O_WONLY or O_RDWR on the fileflags, then this should
34 * fail.
35 */
36void test_forgotten_wronly()
37{
38        libtrace_out_t *out;
39        libtrace_t *trace;
40        libtrace_packet_t *packet;
41        int err;
42        int zero = 0;
43
44        out = trace_create_output("pcapfile:traces/100_packets_out.pcap");
45        assert(out);
46        assert (!trace_is_err_output(out));
47        /* Note: no WRONLY/RDWR */
48        err = trace_config_output(out,TRACE_OPTION_OUTPUT_FILEFLAGS,&zero);
49        assert(err==0);
50        assert(!trace_is_err_output(out));
51
52        err = trace_start_output(out);
53        assert(err == 0);
54        assert(!trace_is_err_output(out));
55
56        trace = trace_create("pcapfile:traces/100_packets.pcap");
57        assert(trace);
58        assert(!trace_is_err(trace));
59       
60        err = trace_start(trace);
61        assert(!trace_is_err(trace));
62        assert(err == 0);
63
64        packet = trace_create_packet();
65        assert(packet);
66
67        err = trace_read_packet(trace, packet);
68        assert(err>0);
69
70        err = trace_write_packet(out,packet);
71        assert(err == -1);              /* Should fail */
72        assert(trace_is_err_output(out)); 
73
74        trace_destroy_output(out);
75        trace_destroy_packet(packet);
76        trace_destroy(trace);
77}
78
79int main(int argc, char *argv[]) 
80{
81       
82        /* This test is no longer useful, as the new libtrace IO system
83         * ensures that all output files are opened with WRONLY, so the
84         * test will always assert fail when the write error does not
85         * occur */
86       
87        /* test_forgotten_wronly(); */
88
89        return 0;
90}
Note: See TracBrowser for help on using the repository browser.