UNIXworkcode

1 /* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 * 4 * Copyright 2019 Olaf Wintermann. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 30 #include <stdio.h> 31 #include <stdlib.h> 32 #include <unistd.h> 33 #include <signal.h> 34 #include <errno.h> 35 #include <pthread.h> 36 37 #include "../util/pool.h" 38 #include "../public/nsapi.h" 39 #include "../util/plist.h" 40 #include "../util/date.h" 41 #include "../daemon/vfs.h" 42 43 #include "test.h" 44 45 #include "vfs.h" 46 #include "writer.h" 47 #include "xml.h" 48 #include "webdav.h" 49 #include "uri.h" 50 #include "object.h" 51 #include "io.h" 52 #include "event.h" 53 54 void register_pg_tests(int argc, char **argv, UcxTestSuite *suite); 55 56 57 void test() { 58 59 } 60 61 // needed for linking 62 WSBool main_is_daemon(void) { 63 return 0; 64 } 65 66 int main(int argc, char **argv) { 67 pool_init(NULL, NULL, NULL); 68 pblock_init_default_keys(); 69 vfs_init(); 70 71 //test(); 72 73 printf("%s", "Webserver Test Suite\n====================\n\n"); 74 75 UcxTestSuite* suite = ucx_test_suite_new(); 76 77 // util tests 78 ucx_test_register(suite, test_util_uri_escape_alphanum); 79 ucx_test_register(suite, test_util_uri_escape_space); 80 ucx_test_register(suite, test_util_uri_escape_latin); 81 ucx_test_register(suite, test_util_uri_escape_kanji); 82 83 // event tests 84 ucx_test_register(suite, test_evhandler_create); 85 ucx_test_register(suite, test_event_send); 86 ucx_test_register(suite, test_event_send_multi); 87 88 // object tests 89 ucx_test_register(suite, test_expr_parse_expr_value); 90 ucx_test_register(suite, test_expr_parse_expr_neg_value); 91 ucx_test_register(suite, test_expr_parse_expr_value_str); 92 ucx_test_register(suite, test_expr_parse_expr_value_bool); 93 ucx_test_register(suite, test_expr_parse_expr_value_var); 94 ucx_test_register(suite, test_expr_parse_expr_not_value); 95 ucx_test_register(suite, test_expr_parse_expr_sign_value); 96 ucx_test_register(suite, test_expr_parse_expr_compare2values); 97 ucx_test_register(suite, test_expr_parse_expr_compare2value_expr); 98 ucx_test_register(suite, test_expr_parse_expr_compare2expr_value); 99 ucx_test_register(suite, test_expr_parse_expr_bracket); 100 ucx_test_register(suite, test_expr_op_defined_simple); 101 ucx_test_register(suite, test_expr_op_defined); 102 ucx_test_register(suite, test_expr_op_file_exists_simple); 103 ucx_test_register(suite, test_expr_parse_expr_func_arg0); 104 ucx_test_register(suite, test_expr_parse_expr_func_arg1); 105 ucx_test_register(suite, test_expr_parse_expr_func_arg3); 106 ucx_test_register(suite, test_expr_parse_expr_func_expr1); 107 ucx_test_register(suite, test_expr_parse_expr_func_expr2); 108 109 // io tests 110 ucx_test_register(suite, test_io_http_stream_parse_chunk_header_hdronly_first); 111 ucx_test_register(suite, test_io_http_stream_parse_chunk_header_hdronly); 112 ucx_test_register(suite, test_io_http_stream_parse_chunk_header_hdronly_seq_fail); 113 ucx_test_register(suite, test_io_http_stream_parse_chunk_header_hdr_data); 114 ucx_test_register(suite, test_io_http_stream_parse_chunk_header_empty); 115 ucx_test_register(suite, test_io_http_stream_parse_chunk_header_partial_first); 116 ucx_test_register(suite, test_io_http_stream_parse_chunk_header_partial); 117 ucx_test_register(suite, test_io_http_stream_parse_chunk_header_invalid); 118 ucx_test_register(suite, test_io_http_stream_parse_chunk_header_zero); 119 ucx_test_register(suite, test_io_httpstream_write); 120 ucx_test_register(suite, test_io_httpstream_chunked_write); 121 ucx_test_register(suite, test_io_httpstream_chunked_write_end); 122 ucx_test_register(suite, test_io_httpstream_chunked_write_xx); 123 ucx_test_register(suite, test_io_httpstream_chunked_write_partial_header); 124 ucx_test_register(suite, test_io_httpstream_chunked_write_partial_data); 125 ucx_test_register(suite, test_io_httpstream_chunked_write_partial_trailer); 126 ucx_test_register(suite, test_io_httpstream_chunked_write_partial_trailer_partial_header); 127 ucx_test_register(suite, test_io_httpstream_chunked_write_data_2x); 128 ucx_test_register(suite, test_io_httpstream_chunked_write_xx_limit); 129 130 // vfs tests 131 ucx_test_register(suite, test_vfs_open); 132 ucx_test_register(suite, test_vfs_mkdir); 133 ucx_test_register(suite, test_vfs_opendir); 134 ucx_test_register(suite, test_vfs_readdir); 135 ucx_test_register(suite, test_vfs_unlink); 136 ucx_test_register(suite, test_vfs_rmdir); 137 138 // writer tests 139 ucx_test_register(suite, test_writer_putc); 140 ucx_test_register(suite, test_writer_flush); 141 ucx_test_register(suite, test_writer_put); 142 143 // xml tests 144 ucx_test_register(suite, test_wsxml_iterator); 145 ucx_test_register(suite, test_wsxml_get_required_namespaces); 146 ucx_test_register(suite, test_wsxml_write_nodes); 147 ucx_test_register(suite, test_wsxml_nslist2string); 148 ucx_test_register(suite, test_wsxml_string2nslist); 149 150 // webdav tests 151 ucx_test_register(suite, test_webdav_plist_add); 152 ucx_test_register(suite, test_webdav_plist_size); 153 ucx_test_register(suite, test_propfind_parse); 154 ucx_test_register(suite, test_proppatch_parse); 155 ucx_test_register(suite, test_lock_parse); 156 ucx_test_register(suite, test_rqbody2buffer); 157 ucx_test_register(suite, test_webdav_plist_iterator); 158 ucx_test_register(suite, test_webdav_plist_iterator_remove_current); 159 ucx_test_register(suite, test_msresponse_addproperty); 160 ucx_test_register(suite, test_webdav_propfind_init); 161 ucx_test_register(suite, test_webdav_op_propfind_begin); 162 ucx_test_register(suite, test_webdav_op_propfind_children); 163 ucx_test_register(suite, test_proppatch_msresponse); 164 ucx_test_register(suite, test_msresponse_addproperty_with_errors); 165 ucx_test_register(suite, test_webdav_op_proppatch); 166 ucx_test_register(suite, test_webdav_vfs_op_do); 167 ucx_test_register(suite, test_webdav_delete); 168 169 // webdav methods 170 ucx_test_register(suite, test_webdav_propfind); 171 ucx_test_register(suite, test_webdav_proppatch); 172 ucx_test_register(suite, test_webdav_put); 173 174 // plugin tests 175 #ifdef ENABLE_POSTGRESQL 176 register_pg_tests(argc, argv, suite); 177 #endif 178 179 // run tests 180 ucx_test_run(suite, stdout); 181 fflush(stdout); 182 183 return EXIT_SUCCESS; 184 } 185 186