Back to index

nagios-plugins  1.4.16
test_tcp.c
Go to the documentation of this file.
00001 /*****************************************************************************
00002 * 
00003 * This program is free software: you can redistribute it and/or modify
00004 * it under the terms of the GNU General Public License as published by
00005 * the Free Software Foundation, either version 3 of the License, or
00006 * (at your option) any later version.
00007 * 
00008 * This program is distributed in the hope that it will be useful,
00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 * GNU General Public License for more details.
00012 * 
00013 * You should have received a copy of the GNU General Public License
00014 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00015 * 
00016 * 
00017 *****************************************************************************/
00018 
00019 #include "common.h"
00020 #include "utils_tcp.h"
00021 #include "tap.h"
00022 
00023 int
00024 main (int argc, char **argv)
00025 {
00026        char** server_expect;
00027        int server_expect_count = 3;
00028        plan_tests(8);
00029 
00030        server_expect = malloc(sizeof(char*) * server_expect_count);
00031 
00032        server_expect[0] = strdup("AA");
00033        server_expect[1] = strdup("bb");
00034        server_expect[2] = strdup("CC");
00035        
00036        ok(np_expect_match("AA bb CC XX", server_expect, server_expect_count, FALSE, TRUE, FALSE) == TRUE,
00037           "Test matching any string at the beginning (first expect string)");
00038        ok(np_expect_match("bb AA CC XX", server_expect, server_expect_count, FALSE, TRUE, FALSE) == TRUE,
00039           "Test matching any string at the beginning (second expect string)");
00040        ok(np_expect_match("XX bb AA CC XX", server_expect, server_expect_count, FALSE, TRUE, FALSE) == FALSE,
00041           "Test with strings not matching at the beginning");
00042        ok(np_expect_match("XX CC XX", server_expect, server_expect_count, FALSE, TRUE, FALSE) == FALSE,
00043           "Test matching any string");
00044        ok(np_expect_match("XX", server_expect, server_expect_count, FALSE, FALSE, FALSE) == FALSE,
00045           "Test not matching any string");
00046        ok(np_expect_match("XX AA bb CC XX", server_expect, server_expect_count, TRUE, FALSE, FALSE) == TRUE,
00047           "Test matching all strings");
00048        ok(np_expect_match("XX bb CC XX", server_expect, server_expect_count, TRUE, FALSE, FALSE) == FALSE,
00049           "Test not matching all strings");
00050        ok(np_expect_match("XX XX", server_expect, server_expect_count, TRUE, FALSE, FALSE) == FALSE,
00051           "Test not matching any string (testing all)");
00052         
00053 
00054        return exit_status();
00055 }
00056