1 //-------------------------------------------------------------------------- 2 // Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 3 // 4 // This program is free software; you can redistribute it and/or modify it 5 // under the terms of the GNU General Public License Version 2 as published 6 // by the Free Software Foundation. You may not use, modify or distribute 7 // this program under any other version of the GNU General Public License. 8 // 9 // This program is distributed in the hope that it will be useful, but 10 // WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 // General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License along 15 // with this program; if not, write to the Free Software Foundation, Inc., 16 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 //-------------------------------------------------------------------------- 18 // http_test_manager.h author Tom Peters <thopeter@cisco.com> 19 20 #ifndef HTTP_TEST_MANAGER_H 21 #define HTTP_TEST_MANAGER_H 22 23 #if defined(REG_TEST) || defined(UNIT_TEST) 24 25 #include <sys/types.h> 26 #include <cstdio> 27 28 //------------------------------------------------------------------------- 29 // HttpTestManager class 30 //------------------------------------------------------------------------- 31 32 class HttpTestInput; 33 34 class HttpTestManager 35 { 36 public: 37 // Bitmap: 1, 2, 4, 8, ... 38 enum INPUT_TYPE { IN_NONE = 0, IN_HTTP = 0x1, IN_HTTP2 = 0x2 }; 39 use_test_input(INPUT_TYPE type)40 static bool use_test_input(INPUT_TYPE type) { return (type & test_input) != 0; } 41 static void activate_test_input(INPUT_TYPE type); activate_test_output(INPUT_TYPE type)42 static void activate_test_output(INPUT_TYPE type) { test_output |= type; } get_test_input_source()43 static HttpTestInput* get_test_input_source() { return test_input_source; } 44 static void update_test_number(int64_t new_test_number); use_test_output(INPUT_TYPE type)45 static bool use_test_output(INPUT_TYPE type) 46 { return (test_output & type) || (test_input & type); } get_output_file()47 static FILE* get_output_file() { return (test_out != nullptr) ? test_out : stdout; } get_test_number()48 static int64_t get_test_number() { return test_number; } set_print_amount(long print_amount_)49 static void set_print_amount(long print_amount_) { print_amount = print_amount_; } get_print_amount()50 static long get_print_amount() { return print_amount; } set_print_hex(bool print_hex_)51 static void set_print_hex(bool print_hex_) { print_hex = print_hex_; } get_print_hex()52 static bool get_print_hex() { return print_hex; } set_show_pegs(bool show_pegs_)53 static void set_show_pegs(bool show_pegs_) { show_pegs = show_pegs_; } get_show_pegs()54 static bool get_show_pegs() { return show_pegs; } set_show_scan(bool show_scan_)55 static void set_show_scan(bool show_scan_) { show_scan = show_scan_; } get_show_scan()56 static bool get_show_scan() { return show_scan; } 57 58 private: 59 HttpTestManager() = delete; 60 61 static unsigned test_input; 62 static HttpTestInput* test_input_source; 63 64 // Printing results of message processing 65 static unsigned test_output; 66 static const char* test_output_prefix; 67 static FILE* test_out; 68 static int64_t test_number; 69 static long print_amount; 70 static bool print_hex; 71 static bool show_pegs; 72 static bool show_scan; 73 }; 74 75 #endif 76 #endif 77 78