xref: /lighttpd1.4/src/t/test_mod_simple_vhost.c (revision 2f7839e8)
1 #include "first.h"
2 
3 #undef NDEBUG
4 #include <assert.h>
5 #include <stdlib.h>
6 #include <stdio.h>
7 
8 #include "mod_simple_vhost.c"
9 
10 static void test_mod_simple_vhost_build_doc_root_path(void) {
11     buffer *sroot = buffer_init();
12     buffer *host  = buffer_init();
13     buffer *droot = buffer_init();
14     buffer *result= buffer_init();
15 
16     buffer_copy_string_len(sroot, CONST_STR_LEN("/sroot/a/"));
17     buffer_copy_string_len(host,  CONST_STR_LEN("www.example.org"));
18     buffer_copy_string_len(droot, CONST_STR_LEN("/droot/b/"));
19     build_doc_root_path(result, sroot, host, droot);
20     assert(buffer_eq_slen(result, CONST_STR_LEN("/sroot/a/www.example.org/droot/b/")));
21 
22     buffer_copy_string_len(host,  CONST_STR_LEN("www.example.org:8080"));
23     build_doc_root_path(result, sroot, host, droot);
24     assert(buffer_eq_slen(result, CONST_STR_LEN("/sroot/a/www.example.org/droot/b/")));
25 
26     buffer_copy_string_len(droot, CONST_STR_LEN(""));
27     build_doc_root_path(result, sroot, host, droot);
28     assert(buffer_eq_slen(result, CONST_STR_LEN("/sroot/a/www.example.org/")));
29 
30     buffer_free(sroot);
31     buffer_free(host);
32     buffer_free(droot);
33     buffer_free(result);
34 }
35 
36 int main (void) {
37     test_mod_simple_vhost_build_doc_root_path();
38 
39     return 0;
40 }
41 
42 /*
43  * stub functions
44  */
45 
46 int stat_cache_path_isdir(const buffer *name) {
47     UNUSED(name);
48     return 1;
49 }
50 
51 int config_plugin_values_init(server *srv, void *p_d, const config_plugin_keys_t *cpk, const char *mname) {
52     UNUSED(srv);
53     UNUSED(p_d);
54     UNUSED(cpk);
55     UNUSED(mname);
56     return 0;
57 }
58 
59 int config_check_cond(request_st *r, int context_ndx) {
60     UNUSED(r);
61     UNUSED(context_ndx);
62     return 0;
63 }
64