├── .gitignore ├── .travis.yml ├── CHANGELOG.mdown ├── LICENSE ├── README.md ├── SConstruct ├── Vagrantfile ├── bench.c ├── deps ├── check-0.9.8 │ ├── AUTHORS │ ├── COPYING.LESSER │ ├── ChangeLog │ ├── ChangeLogOld │ ├── INSTALL │ ├── Makefile │ ├── Makefile.am │ ├── Makefile.in │ ├── NEWS │ ├── README │ ├── SVNChangeLog │ ├── THANKS │ ├── TODO │ ├── aclocal.m4 │ ├── build-aux │ │ ├── compile │ │ ├── config.guess │ │ ├── config.sub │ │ ├── depcomp │ │ ├── install-sh │ │ ├── ltmain.sh │ │ ├── mdate-sh │ │ ├── missing │ │ └── texinfo.tex │ ├── check.m4 │ ├── check.pc │ ├── check.pc.in │ ├── config.h │ ├── config.h.in │ ├── config.log │ ├── config.status │ ├── configure │ ├── configure.ac │ ├── doc │ │ ├── Makefile │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── check.info │ │ ├── check.texi │ │ ├── example │ │ │ ├── Makefile.am │ │ │ ├── README │ │ │ ├── configure.ac │ │ │ ├── src │ │ │ │ ├── Makefile.am │ │ │ │ ├── main.c │ │ │ │ ├── money.1.c │ │ │ │ ├── money.1.h │ │ │ │ ├── money.2.h │ │ │ │ ├── money.3.c │ │ │ │ ├── money.4.c │ │ │ │ ├── money.5.c │ │ │ │ ├── money.6.c │ │ │ │ ├── money.c │ │ │ │ └── money.h │ │ │ └── tests │ │ │ │ ├── Makefile.am │ │ │ │ ├── check_money.1.c │ │ │ │ ├── check_money.2.c │ │ │ │ ├── check_money.3.c │ │ │ │ ├── check_money.6.c │ │ │ │ ├── check_money.7.c │ │ │ │ └── check_money.c │ │ ├── fdl.texi │ │ ├── stamp-vti │ │ └── version.texi │ ├── lib │ │ ├── .deps │ │ │ ├── fileno.Plo │ │ │ ├── libcompat.Plo │ │ │ ├── localtime_r.Plo │ │ │ ├── malloc.Plo │ │ │ ├── pipe.Plo │ │ │ ├── putenv.Plo │ │ │ ├── realloc.Plo │ │ │ ├── setenv.Plo │ │ │ ├── sleep.Plo │ │ │ ├── strdup.Plo │ │ │ ├── strsignal.Plo │ │ │ └── unsetenv.Plo │ │ ├── Makefile │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── fileno.c │ │ ├── libcompat.c │ │ ├── libcompat.h │ │ ├── localtime_r.c │ │ ├── malloc.c │ │ ├── pipe.c │ │ ├── putenv.c │ │ ├── realloc.c │ │ ├── setenv.c │ │ ├── sleep.c │ │ ├── strdup.c │ │ ├── strsignal.c │ │ └── unsetenv.c │ ├── libtool │ ├── m4 │ │ ├── acx_pthread.m4 │ │ ├── ax_c_check_flag.m4 │ │ ├── ax_cflags_warn_all_ansi.m4 │ │ ├── libtool.m4 │ │ ├── ltoptions.m4 │ │ ├── ltsugar.m4 │ │ ├── ltversion.m4 │ │ └── lt~obsolete.m4 │ ├── src │ │ ├── .deps │ │ │ ├── check.Plo │ │ │ ├── check_error.Plo │ │ │ ├── check_list.Plo │ │ │ ├── check_log.Plo │ │ │ ├── check_msg.Plo │ │ │ ├── check_pack.Plo │ │ │ ├── check_print.Plo │ │ │ ├── check_run.Plo │ │ │ └── check_str.Plo │ │ ├── Makefile │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── check.c │ │ ├── check.h │ │ ├── check.h.in │ │ ├── check_error.c │ │ ├── check_error.h │ │ ├── check_impl.h │ │ ├── check_list.c │ │ ├── check_list.h │ │ ├── check_log.c │ │ ├── check_log.h │ │ ├── check_msg.c │ │ ├── check_msg.h │ │ ├── check_pack.c │ │ ├── check_pack.h │ │ ├── check_print.c │ │ ├── check_print.h │ │ ├── check_run.c │ │ ├── check_str.c │ │ └── check_str.h │ ├── stamp-h1 │ └── tests │ │ ├── .deps │ │ ├── check_check-check_check_exit.Po │ │ ├── check_check-check_check_fixture.Po │ │ ├── check_check-check_check_fork.Po │ │ ├── check_check-check_check_limit.Po │ │ ├── check_check-check_check_log.Po │ │ ├── check_check-check_check_log_internal.Po │ │ ├── check_check-check_check_main.Po │ │ ├── check_check-check_check_master.Po │ │ ├── check_check-check_check_msg.Po │ │ ├── check_check-check_check_pack.Po │ │ ├── check_check-check_check_sub.Po │ │ ├── check_check-check_list.Po │ │ ├── check_check_export-check_check_export_main.Po │ │ ├── check_check_export-check_check_fork.Po │ │ ├── check_check_export-check_check_log.Po │ │ ├── check_check_export-check_check_master.Po │ │ ├── check_check_export-check_check_sub.Po │ │ ├── check_stress.Po │ │ ├── check_thread_stress-check_thread_stress.Po │ │ ├── ex_log_output.Po │ │ ├── ex_output.Po │ │ └── ex_xml_output.Po │ │ ├── Makefile │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── check_check.h │ │ ├── check_check_exit.c │ │ ├── check_check_export_main.c │ │ ├── check_check_fixture.c │ │ ├── check_check_fork.c │ │ ├── check_check_limit.c │ │ ├── check_check_log.c │ │ ├── check_check_log_internal.c │ │ ├── check_check_main.c │ │ ├── check_check_master.c │ │ ├── check_check_msg.c │ │ ├── check_check_pack.c │ │ ├── check_check_sub.c │ │ ├── check_list.c │ │ ├── check_stress.c │ │ ├── check_thread_stress.c │ │ ├── ex_log_output.c │ │ ├── ex_output.c │ │ ├── ex_xml_output.c │ │ ├── test_log_output.sh │ │ ├── test_output.sh │ │ ├── test_vars │ │ ├── test_vars.in │ │ └── test_xml_output.sh ├── inih │ ├── LICENSE.txt │ ├── README.txt │ ├── ini.c │ └── ini.h ├── libev │ ├── CVS │ │ ├── Entries │ │ ├── Repository │ │ └── Root │ ├── Changes │ ├── LICENSE │ ├── Makefile.am │ ├── README │ ├── README.embed │ ├── Symbols.ev │ ├── Symbols.event │ ├── autogen.sh │ ├── configure.ac │ ├── ev++.h │ ├── ev.3 │ ├── ev.c │ ├── ev.h │ ├── ev.pod │ ├── ev_epoll.c │ ├── ev_kqueue.c │ ├── ev_poll.c │ ├── ev_port.c │ ├── ev_select.c │ ├── ev_vars.h │ ├── ev_win32.c │ ├── ev_wrap.h │ ├── event.c │ ├── event.h │ ├── event_compat.h │ ├── import_libevent │ ├── libev.m4 │ ├── update_ev_c │ ├── update_ev_wrap │ └── update_symbols └── murmurhash │ ├── MurmurHash3.cpp │ └── MurmurHash3.h ├── integ └── test_integ.py ├── src ├── art.c ├── art.h ├── background.c ├── background.h ├── barrier.c ├── barrier.h ├── bitmap.c ├── bitmap.h ├── config.c ├── config.h ├── conn_handler.c ├── conn_handler.h ├── handler_constants.c ├── hll.c ├── hll.h ├── hll_constants.c ├── hll_constants.h ├── hlld.c ├── networking.c ├── networking.h ├── set.c ├── set.h ├── set_manager.c ├── set_manager.h ├── spinlock.h └── type_compat.h └── tests ├── runner.c ├── test_art.c ├── test_bitmap.c ├── test_config.c ├── test_hll.c ├── test_set.c ├── test_setmgr.c └── words.txt /.gitignore: -------------------------------------------------------------------------------- 1 | *.a 2 | *.dylib 3 | *.o 4 | *.os 5 | .lvimrc 6 | .sconsign.dblite 7 | tests/build/ 8 | deps/check-0.9.8 9 | .vagrant 10 | *.pyc 11 | test_runner 12 | hlld 13 | bench 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "2.7" 4 | before_install: 5 | - sudo apt-get -y install scons 6 | - pushd deps/check-0.9.8 7 | - ./configure 8 | - make 9 | - sudo make install 10 | - sudo ldconfig 11 | - popd 12 | - scons hlld test_runner 13 | install: pip install pytest==2.3.4 --use-mirrors 14 | script: ./test_runner && py.test integ/ 15 | -------------------------------------------------------------------------------- /CHANGELOG.mdown: -------------------------------------------------------------------------------- 1 | # 0.5.4 2 | 3 | * Bug fix for potential issues related to non-ASCII filter names 4 | * Git SHA: 7e2a973 5 | 6 | # 0.5.3 7 | 8 | * Adding support for bind\_address 9 | * Git SHA: 12a67ab 10 | 11 | # 0.5.2 12 | * Bug fixes for background tasks being invoked too often 13 | * Git SHA: 1c58072 14 | 15 | # 0.5.1 16 | * Increase the safety of connection handling. Prevents some crashing 17 | conditions. 18 | * Reduce checkpoint intervals from 1 second to 250 milliseconds. This 19 | allows faster cleanups, and helps prevent "Delete in progress" errors. 20 | * Git SHA: 0d36e87 21 | 22 | # 0.5.0 23 | 24 | * Major rewrite of the internal Multi-Version Concurrency Controll (MVCC). 25 | The old system was based on a single set map per version, along side a 26 | vacuum thread to do periodic cleanup. This did not scale well as each version 27 | had to copy the map of the last version, and since many versions could exist 28 | concurrently, it is possible for the heap to explode to many hundreds of MB or 29 | GB worth of just versioning information. Instead, we now maintain only 2 maps, 30 | a "primary" and "alternate", and make use of a list of delta updates. The vacuum 31 | thread now manages applying delta updates to the alternate map and rotating the 32 | primary and alternate. This reduces the memory overhead, and reduces the cost 33 | of creating a new version (create, drop, clear). 34 | * List ordering is no longer well defined due to delta lists 35 | * Reduced number of log messages 36 | * Slow flush and unmap operations still allow vacuum to make progress 37 | * Git SHA: 9a440fd 38 | 39 | # 0.2.3 40 | 41 | * Reduce various messages from INFO to DEBUG level 42 | * Change default log level to INFO. Previously, syslog would 43 | be overwhelmed by the amount of logging messages. 44 | * Provide timing info for all the flush and unmap operations as INFO level 45 | message, instead of per-set info at DEBUG level 46 | * Improve thread safety in some cases where a set may be unmapped 47 | while being used 48 | * Git SHA: f3d9de2 49 | 50 | # 0.2.2 51 | 52 | * Fixed bugs involving sets with very long common prefixes 53 | * Git SHA: c3d0730 54 | 55 | # 0.2.0 56 | 57 | * Replace internal hashmap with an Adaptive Radix Tree (ART). This 58 | improves the create/drop time for instances with many many sets. 59 | * `list` command now can take a prefix and returns only sets matching 60 | * As a result of the ART tree, list results are sorted in descending order 61 | * Git SHA: a07e29b 62 | 63 | # 0.1.0 64 | 65 | * Initial Release 66 | * Git SHA: 85a34d8 67 | 68 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012, Armon Dadgar 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of the organization nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL ARMON DADGAR BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | -------------------------------------------------------------------------------- /SConstruct: -------------------------------------------------------------------------------- 1 | import platform 2 | plat = platform.system() 3 | 4 | envmurmur = Environment(CPPPATH = ['deps/murmurhash/'], CPPFLAGS="-fno-exceptions -O2") 5 | murmur = envmurmur.Library('murmur', Glob("deps/murmurhash/*.cpp")) 6 | 7 | envinih = Environment(CPATH = ['deps/inih/'], CFLAGS="-O2") 8 | inih = envinih.Library('inih', Glob("deps/inih/*.c")) 9 | 10 | env_with_err = Environment(CCFLAGS = '-g -std=c99 -D_GNU_SOURCE -Wall -Wextra -Werror -O2 -pthread -Isrc/ -Ideps/inih/ -Ideps/libev/') 11 | env_without_unused_err = Environment(CCFLAGS = '-g -std=c99 -D_GNU_SOURCE -Wall -Wextra -Wno-unused-function -Wno-unused-result -Werror -O2 -pthread -Isrc/ -Ideps/inih/ -Ideps/libev/') 12 | env_without_err = Environment(CCFLAGS = '-g -std=c99 -D_GNU_SOURCE -O2 -pthread -Isrc/ -Ideps/inih/ -Ideps/libev/') 13 | 14 | objs = env_with_err.Object('src/config', 'src/config.c') + \ 15 | env_with_err.Object('src/barrier', 'src/barrier.c') + \ 16 | env_with_err.Object('src/hll', 'src/hll.c') + \ 17 | env_with_err.Object('src/hll_constants', 'src/hll_constants.c') + \ 18 | env_with_err.Object('src/bitmap', 'src/bitmap.c') + \ 19 | env_with_err.Object('src/set', 'src/set.c') + \ 20 | env_with_err.Object('src/set_manager', 'src/set_manager.c') + \ 21 | env_without_err.Object('src/networking', 'src/networking.c') + \ 22 | env_with_err.Object('src/conn_handler', 'src/conn_handler.c') + \ 23 | env_with_err.Object('src/background', 'src/background.c') + \ 24 | env_with_err.Object('src/art', 'src/art.c') 25 | 26 | libs = ["pthread", murmur, inih, "m"] 27 | if plat == 'Linux': 28 | libs.append("rt") 29 | 30 | hlld = env_with_err.Program('hlld', objs + ["src/hlld.c"], LIBS=libs) 31 | 32 | if plat == "Darwin": 33 | test = env_without_err.Program('test_runner', objs + Glob("tests/runner.c"), LIBS=libs + ["check"]) 34 | else: 35 | test = env_without_unused_err.Program('test_runner', objs + Glob("tests/runner.c"), LIBS=libs + ["check"]) 36 | 37 | bench_obj = Object("bench", "bench.c", CCFLAGS="-std=c99 -O2") 38 | Program('bench', bench_obj, LIBS=["pthread"]) 39 | 40 | # By default, only compile hlld 41 | Default(hlld) 42 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | $script = < $script 20 | end 21 | -------------------------------------------------------------------------------- /bench.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | static int NUM_THREADS = 1; 14 | static int NUM_KEYS = 1000000; 15 | static char* HOST = "127.0.0.1"; 16 | static int PORT = 4553; 17 | static char *SET_NAME = "foobar%d"; 18 | 19 | typedef struct { 20 | int conn_fd; 21 | char set_name[32]; 22 | char cmd_buf[128]; 23 | } conn_info; 24 | 25 | int connect_fd(conn_info *info) { 26 | struct sockaddr_in addr; 27 | bzero(&addr, sizeof(addr)); 28 | addr.sin_family = PF_INET; 29 | addr.sin_port = htons(PORT); 30 | inet_pton(PF_INET, HOST, &addr.sin_addr); 31 | 32 | info->conn_fd = socket(PF_INET, SOCK_STREAM, 0); 33 | return connect(info->conn_fd, (struct sockaddr*)&addr, sizeof(addr)); 34 | } 35 | 36 | int timediff(struct timeval *t1, struct timeval *t2) { 37 | uint64_t micro1 = t1->tv_sec * 1000000 + t1->tv_usec; 38 | uint64_t micro2= t2->tv_sec * 1000000 + t2->tv_usec; 39 | return (micro2-micro1) / 1000; 40 | } 41 | 42 | void *thread_main(void *in) { 43 | printf("Thread started."); 44 | conn_info info; 45 | int sets = 0; 46 | 47 | // Generate a set name 48 | char *buf = (char*)&info.set_name; 49 | sprintf(buf, SET_NAME, rand()); 50 | printf("Using set: %s\n", buf); 51 | 52 | struct timeval start_connect, start_create, start_set, start_check, end; 53 | char out_buf[16]; 54 | int num, sent, len; 55 | 56 | // Connect 57 | gettimeofday(&start_connect, NULL); 58 | int res = connect_fd(&info); 59 | if (res) { 60 | printf("Failed to connect!"); 61 | return NULL; 62 | } 63 | gettimeofday(&end, NULL); 64 | printf("Connect: %d msec\n", timediff(&start_connect, &end)); 65 | 66 | // Make set 67 | gettimeofday(&start_create, NULL); 68 | 69 | len = sprintf((char*)&info.cmd_buf, "create %s\n", buf); 70 | send(info.conn_fd, info.cmd_buf, len, 0); 71 | num = recv(info.conn_fd, (char*)&out_buf, 5, 0); 72 | if (strcmp(out_buf, "Done\n") != 0) { 73 | printf("Failed to create set!"); 74 | return NULL; 75 | } 76 | 77 | gettimeofday(&end, NULL); 78 | printf("Create: %d msec\n", timediff(&start_create, &end)); 79 | 80 | // Set 81 | gettimeofday(&start_set, NULL); 82 | for (int i=0; i< NUM_KEYS; i++) { 83 | sprintf((char*)&info.cmd_buf, "set %s test%d\n", buf, i); 84 | sent = send(info.conn_fd, (char*)&info.cmd_buf, strlen(info.cmd_buf), 0); 85 | if (sent == -1) { 86 | printf("Failed to send!"); 87 | return NULL; 88 | } 89 | } 90 | 91 | for (int i=0; i< NUM_KEYS; i++) { 92 | int remain = 5; 93 | while (remain) { 94 | num = recv(info.conn_fd, (char*)out_buf, remain, 0); 95 | if (num == -1) { 96 | printf("Failed to read! Iter: %d. Res: %d\n", i, num); 97 | return NULL; 98 | } 99 | remain -= num; 100 | } 101 | sets++; 102 | } 103 | gettimeofday(&end, NULL); 104 | printf("Set: %d msec. Num: %d\n", timediff(&start_set, &end), sets); 105 | 106 | sprintf((char*)&info.cmd_buf, "drop %s\n", buf); 107 | sent = send(info.conn_fd, (char*)&info.cmd_buf, strlen(info.cmd_buf), 0); 108 | 109 | return NULL; 110 | } 111 | 112 | int main(int argc, char **argv) { 113 | // Read random seed 114 | int randfh = open("/dev/random", O_RDONLY); 115 | unsigned seed = 0; 116 | read(randfh, &seed, sizeof(seed)); 117 | close(randfh); 118 | 119 | srand(seed); 120 | pthread_t t[NUM_THREADS]; 121 | for (int i=0; i< NUM_THREADS; i++) { 122 | pthread_create(&t[i], NULL, thread_main, NULL); 123 | } 124 | for (int i=0; i< NUM_THREADS; i++) { 125 | pthread_join(t[i], NULL); 126 | } 127 | return 0; 128 | } 129 | -------------------------------------------------------------------------------- /deps/check-0.9.8/AUTHORS: -------------------------------------------------------------------------------- 1 | Maintainers: Fredrik Hugosson 2 | Chris Pickett 3 | 4 | Ex-Maintainer: Sven Neumann 5 | Original Author: Arien Malec 6 | 7 | Patches: Bernhard Reiter (configure issues) 8 | Neil Spring (const fixes) 9 | Rick Poyner (pipe handling, bug fixes) 10 | Dietmar Petras (bug fixes) 11 | Gilgamesh Nootebos (bug fixes) 12 | Frederic Peters (XML output) 13 | Lucas Di Pentima and Cesar Ballardini (signals) 14 | Robert Lemmen (gcov description in manual) 15 | Loic Martin (AM_PATH_CHECK patch) 16 | Ross Burton (pkg-config patch) 17 | Roland Stigge (bug fix: allow fail inside setup) 18 | Torok Edwin (strsignal and build fixes) 19 | Roland Illig (varargs and strsignal portability fixes) 20 | Daniel Gollub (pthreads support) 21 | Friedrich Beckmann (mingw and msvc port) 22 | Roy Merkel (specified test exit value) 23 | Robert Collins (subunit support) 24 | 25 | Anybody who has contributed code to Check or Check's build system is 26 | considered an author. Send patches to this file to 27 | . 28 | -------------------------------------------------------------------------------- /deps/check-0.9.8/ChangeLogOld: -------------------------------------------------------------------------------- 1 | Revisions previous to move to SourceForge 2 | 2001-05-25 05:56 amalec 3 | 4 | * src/check_msg.c, src/check_msg.h, tests/Makefile.am, 5 | tests/check_check_msg.c: Added testcases for check_msg 6 | 7 | 2001-05-25 05:25 amalec 8 | 9 | * ChangeLog: Update ChangeLog 10 | 11 | 2001-05-25 05:25 amalec 12 | 13 | * configure, src/Makefile.am, src/check.c, src/check.h, 14 | src/check_impl.h, src/check_run.c, src/check_run.h, 15 | tests/check_check.c, tests/check_list.c, tests/check_stress.c: 16 | Added fixture support and moved suite running functions to main 17 | check.h header 18 | 19 | 2001-05-23 20:29 amalec 20 | 21 | * ChangeLog, configure.in: Bumped version 22 | 23 | 2001-05-23 20:28 amalec 24 | 25 | * src/check.h, src/check_impl.h, src/check_msg.c, src/check_msg.h, 26 | src/check_run.c, src/check_run.h, tests/check_check.c, 27 | tests/check_list.c, tests/check_stress.c: Changed check_check to 28 | run silently if no errors 29 | 30 | 2001-05-22 16:15 amalec 31 | 32 | * src/Makefile.am, tests/Makefile.am: Cleanup of move to a non-flat 33 | directory structure 34 | 35 | 2001-05-22 16:15 amalec 36 | 37 | * Makefile.am, Makefile.in, check.c, check.h, check_check.c, 38 | check_impl.h, check_list.c, check_msg.c, check_msg.h, check_run.h, 39 | configure, configure.in, error.c, error.h, list.c, list.h, 40 | src/check.c, src/check.h, src/check_impl.h, src/check_msg.c, 41 | src/check_msg.h, src/check_run.c, src/check_run.h, src/error.c, 42 | src/error.h, src/list.c, src/list.h, tests/check_check.c, 43 | tests/check_list.c, tests/check_stress.c: Moved to a non-flat 44 | directory structure 45 | 46 | 2001-05-22 14:53 amalec 47 | 48 | * ChangeLog: Update ChangeLog 49 | 50 | 2001-05-22 14:52 amalec 51 | 52 | * Makefile.am, Makefile.in, check.c, check.h, check_check.c, 53 | check_list.c, check_run.h, config.h.in, configure, configure.in, 54 | error.c, error.h, list.c: Switched to a dynamically grown array 55 | implementation for lists, to solve a performance problem forking 56 | with large numbers of tests; fixed a memory problem in srunner_free 57 | 58 | 2001-05-18 12:31 amalec 59 | 60 | * ChangeLog: Useing cvs2cl.pl to handle ChangeLog 61 | 62 | 2001-05-18 12:02 amalec 63 | 64 | * check_run.h, configure, stamp-h.in: More code reorgazization 65 | 66 | 2001-05-16 11:20 amalec 67 | 68 | * check.c, check_check.c, check_msg.c, check_msg.h, check_run.h, 69 | configure.in: Cleaned up memory leaks and rearranged some 70 | responsibilities 71 | 72 | 2001-05-15 17:36 amalec 73 | 74 | * check.c, check.h, check_check.c, check_impl.h, check_list.c, 75 | check_msg.c, check_msg.h, check_run.h: Addition of SRunner object, 76 | and major reorganization of responsibilites between suites/cases 77 | and the SRunner 78 | 79 | 2001-05-15 15:11 amalec 80 | 81 | * list.c: Added list_add_end function 82 | 83 | 2001-05-15 09:20 amalec 84 | 85 | * Makefile.am, Makefile.in: Cleaned up Makefile.am to declare 86 | headers correctly, and install correctly. 87 | 88 | 2001-05-14 18:06 amalec 89 | 90 | * check.c, check.h, check_impl.h, check_run.h: Completed 91 | reorganization 92 | 93 | 2001-05-14 17:33 amalec 94 | 95 | * Makefile.in, check.c, check_run.h: Complete commit of last 96 | changes 97 | 98 | 2001-05-14 17:30 amalec 99 | 100 | * Makefile.am, check.h, check_check.c, check_list.c, check_run.h: 101 | Cleaned up some documentation, and moved suite printing functions 102 | to a separate module as a first step to separating the text runner 103 | from the underlying interface. 104 | 105 | 2001-05-14 17:07 amalec 106 | 107 | * AUTHORS, ChangeLog, Makefile.am, Makefile.in, NEWS, README, 108 | aclocal.m4, check.c, check.h, check_check.c, check_impl.h, 109 | check_list.c, check_msg.c, check_msg.h, config.h.in, configure, 110 | configure.in, error.c, error.h, list.c, list.h, stamp-h.in: Initial 111 | revision 112 | 113 | 2001-05-14 17:07 amalec 114 | 115 | * AUTHORS, ChangeLog, Makefile.am, Makefile.in, NEWS, README, 116 | aclocal.m4, check.c, check.h, check_check.c, check_impl.h, 117 | check_list.c, check_msg.c, check_msg.h, config.h.in, configure, 118 | configure.in, error.c, error.h, list.c, list.h, stamp-h.in: 119 | Imported sources 120 | 121 | -------------------------------------------------------------------------------- /deps/check-0.9.8/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | ## run tests after everything else 4 | 5 | SUBDIRS = lib src doc . tests 6 | 7 | ## FIXME: maybe we don't need this line 8 | 9 | AM_MAKEINFOFLAGS = -I$(top_srcdir)/doc/example 10 | 11 | ## what to clean 12 | 13 | CLEANFILES = *~\ 14 | $(PACKAGE)-$(VERSION).tar.gz\ 15 | ChangeLog.bak 16 | 17 | ## what additional things to distribute 18 | 19 | EXTRA_DIST = SVNChangeLog ChangeLogOld check.pc.in $(m4data_DATA) 20 | 21 | ## install docs 22 | docdir = $(datadir)/doc/$(PACKAGE) 23 | doc_DATA = SVNChangeLog ChangeLog ChangeLogOld NEWS README COPYING.LESSER 24 | 25 | ## install check.m4 with AM_PATH_CHECK in it 26 | m4datadir = $(datadir)/aclocal 27 | m4data_DATA = check.m4 28 | 29 | ## install check.pc 30 | pcdatadir = $(libdir)/pkgconfig 31 | pcdata_DATA = check.pc 32 | 33 | SVNChangeLog: 34 | if [ -e .svn ] ; then \ 35 | svn log -v @abs_top_srcdir@ > $@ ;\ 36 | else \ 37 | echo "SVN Changelog not available" > $@ ;\ 38 | fi 39 | 40 | ACLOCAL_AMFLAGS = -I m4 41 | 42 | doc/check.html: 43 | $(MAKE) -C doc check.html 44 | 45 | # check we can do a clean build, including docs. 46 | # perhaps we should check for out of date (svn st -u) and modified files. 47 | prereleasecheck: doc/check.html 48 | -$(MAKE) distclean 49 | autoreconf -i && ./configure \ 50 | && ulimit -c 0 && \ 51 | $(MAKE) distcheck 52 | 53 | RELEASE_VERSION ?= unset 54 | SF_USERNAME ?= unset 55 | releasevars: 56 | @if [ "unset" = "${RELEASE_VERSION}" ]; then \ 57 | echo "set RELEASE_VERSION to something like 0.9.6 to prepare a release."; \ 58 | false; \ 59 | fi 60 | @if [ "unset" = "${SF_USERNAME}" ]; then \ 61 | echo "set SF_USERNAME to your sourceforge username"; \ 62 | false; \ 63 | fi 64 | 65 | .svnrelease: 66 | svn st -u | grep "Status against revision:" | awk '{ print $$4 }' > $@ 67 | 68 | preparerelease: releasevars .svnrelease prereleasecheck 69 | @echo checking we have can connect properly to do release tasks before tagging: 70 | sftp -b /dev/null ${SF_USERNAME}@web.sourceforge.net 71 | sftp -b /dev/null ${SF_USERNAME}@frs.sourceforge.net 72 | @echo tagging release from `cat .svnrelease` 73 | svn cp -m "Release check-${RELEASE_VERSION}" -r`cat .svnrelease` https://svn.sourceforge.net/svnroot/check/trunk https://svn.sourceforge.net/svnroot/check/tags/check-${RELEASE_VERSION} 74 | svn co https://svn.sourceforge.net/svnroot/check/tags/check-${RELEASE_VERSION} check-${RELEASE_VERSION} 75 | @echo "You need to:" 76 | @echo "Update TODO and make sure version numbers match appropriately." 77 | @echo "Update configure.ac with new version numbers." 78 | @echo "Then svn commit these changes." 79 | @echo "CTRL-D when finished or 'exit 1' to abort." 80 | @echo "aborting will leave the partially prepared release in" `pwd` 81 | cd check-${RELEASE_VERSION} && ${SHELL} && autoreconf -i && ./configure 82 | $(MAKE) -C check-${RELEASE_VERSION} dorelease 83 | -svn merge -r`cat .svnrelease`:`svn st -u check-${RELEASE_VERSION} | grep "Status against revision:" | awk '{ print $4 }'` check-${RELEASE_VERSION} . 84 | @echo "Please resolve any conflicts. Be sure to also restore the 'In Development:' line to NEWS." 85 | ${SHELL} 86 | svn ci -m "Merge back release ${RELEASE_VERSION}" 87 | @echo "Cleaning up workdir." 88 | rm -rf check-${RELEASE_VERSION} 89 | 90 | 91 | dorelease: releasevars doc/check.html prereleasecheck 92 | cp NEWS NEWS-${RELEASE_VERSION}.txt 93 | @echo "You need to:" 94 | @echo "cut out old release news from NEWS-${RELEASE_VERSION}.txt." 95 | @echo "CTRL-D to complete, or exit 1 to abort." 96 | ${SHELL} 97 | @echo uploading... 98 | rsync -e ssh NEWS-${RELEASE_VERSION}.txt ${SF_USERNAME},check@frs.sourceforge.net:/home/frs/project/c/ch/check/check/${RELEASE_VERSION}/ 99 | rsync -e ssh check-${RELEASE_VERSION}.tar.gz ${SF_USERNAME},check@frs.sourceforge.net:/home/frs/project/c/ch/check/check/${RELEASE_VERSION}/ 100 | rsync -rlvC doc/. ${SF_USERNAME},check@web.sourceforge.net:/home/groups/c/ch/check/htdocs 101 | @echo 102 | @echo Uploaded... 103 | @echo "visit https://sourceforge.net/project/admin/explorer.php?group_id=28255" 104 | @echo "Mark the NEWS file in check/${RELEASE_VERSION} as being a release note." 105 | @echo "And the tar.gz file as being 'all platforms', using the NEWS file for release notes." 106 | @echo "visit https://sourceforge.net/projects/check/files/" 107 | @echo "Check it looks ok. It may take 15 minutes to show up." 108 | @echo Finally, mail check-devel ,announce and users at lists dot sourceforge dot net 109 | @echo an email (template is in HACKING) about this announcement. 110 | @echo NEWS-release can be found at `pwd`/NEWS-${RELEASE_VERSION}.txt 111 | @echo Note that with the tarballs, docs amd NEWS up, the release is done :P 112 | @echo "so you'll have to manually roll back if you abort." 113 | @echo "CTRL-D to complete, or exit 1 to abort." 114 | ${SHELL} 115 | 116 | 117 | .PHONY: releasevars prereleasecheck preparerelease dorelease .svnrelease 118 | -------------------------------------------------------------------------------- /deps/check-0.9.8/README: -------------------------------------------------------------------------------- 1 | About Check 2 | ----------- 3 | 4 | Check is a unit testing framework for C. It features a simple interface 5 | for defining unit tests, putting little in the way of the 6 | developer. Tests are run in a separate address space, so Check can 7 | catch both assertion failures and code errors that cause segmentation 8 | faults or other signals. The output from unit tests can be used within 9 | source code editors and IDEs. 10 | 11 | See http://check.sourceforge.net/ for more information, including a 12 | tutorial. The tutorial is also available as `info check'. 13 | 14 | Installation 15 | ------------ 16 | 17 | Check has the following dependencies: 18 | 19 | automake-1.9.6 20 | autoconf-2.59 21 | libtool-1.5.22 22 | pkg-config-0.20 23 | texinfo-4.7 (for documentation) 24 | tetex-bin (or any texinfo-compatible TeX installation, for documentation) 25 | POSIX sed 26 | 27 | The versions specified may be higher than those actually needed. 28 | 29 | First, do 30 | 31 | $ autoreconf --install 32 | 33 | in this directory to set everything up. autoreconf calls all of the 34 | necessary tools for you, like autoconf, automake, autoheader, etc. If 35 | you ever change something during development, run autoreconf again 36 | (without --install), and it will perform the minimum set of actions 37 | necessary. 38 | 39 | Then, read the directions in INSTALL if you need more information. 40 | 41 | Linking against Check 42 | --------------------- 43 | 44 | Check uses variadic macros in check.h, and the strict C90 options for 45 | gcc will complain about this. In gcc 4.0 and above you can turn this 46 | off explicitly with -Wno-variadic-macros. In a future API it would be 47 | nice to eliminate these macros. 48 | 49 | Debian rationale for not having upstream build packages (.deb files) 50 | -------------------------------------------------------------------- 51 | 52 | For debian, it is highly undesirable if the upstream source contains a 53 | debian directory as this one will never be the same as the "official" 54 | Debian one, and patching is easier if it's not around. 55 | 56 | Sometimes upstream insists on having the possibility to build Debian 57 | packages themselves, in which case it is best to have a debian 58 | directory in the CVS, but not ship it when doing "make dist". 59 | 60 | Sometimes upstream insists on shipping the debian directory to their 61 | users so these can easily build a .deb, which is really bad because 62 | they usually don't remmeber to change the Debian changelog and version 63 | accordingly, and generally don't know enough about Debian policy to 64 | make conforming packages. 65 | 66 | So in the end you will have different broken packages compiled on 67 | various systems floating around which all have the same version number 68 | and look like offical packages. 69 | 70 | -- Robert Lemmen, 2006 71 | 72 | The same holds for .rpm packages. The Check maintainer for Fedora 73 | Extras, Tom 'spot' Callaway, confirmed that they do not depend on an 74 | upstream rpm target in Check. 75 | -------------------------------------------------------------------------------- /deps/check-0.9.8/THANKS: -------------------------------------------------------------------------------- 1 | Design suggestions: 2 | Fred Drake (checked fixture functions) 3 | Jim O'Leary (forkless mode) 4 | 5 | Downstream maintainers: 6 | Robert Lemmen (Debian) 7 | Tom 'spot' Callaway (Fedora Extras) 8 | 9 | If you helped out with Check in some way and would like to be listed 10 | here, send a patch to . 11 | -------------------------------------------------------------------------------- /deps/check-0.9.8/build-aux/compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Wrapper for compilers which do not understand `-c -o'. 3 | 4 | scriptversion=2005-05-14.22 5 | 6 | # Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 7 | # Written by Tom Tromey . 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | 23 | # As a special exception to the GNU General Public License, if you 24 | # distribute this file as part of a program that contains a 25 | # configuration script generated by Autoconf, you may include it under 26 | # the same distribution terms that you use for the rest of that program. 27 | 28 | # This file is maintained in Automake, please report 29 | # bugs to or send patches to 30 | # . 31 | 32 | case $1 in 33 | '') 34 | echo "$0: No command. Try \`$0 --help' for more information." 1>&2 35 | exit 1; 36 | ;; 37 | -h | --h*) 38 | cat <<\EOF 39 | Usage: compile [--help] [--version] PROGRAM [ARGS] 40 | 41 | Wrapper for compilers which do not understand `-c -o'. 42 | Remove `-o dest.o' from ARGS, run PROGRAM with the remaining 43 | arguments, and rename the output as expected. 44 | 45 | If you are trying to build a whole package this is not the 46 | right script to run: please start by reading the file `INSTALL'. 47 | 48 | Report bugs to . 49 | EOF 50 | exit $? 51 | ;; 52 | -v | --v*) 53 | echo "compile $scriptversion" 54 | exit $? 55 | ;; 56 | esac 57 | 58 | ofile= 59 | cfile= 60 | eat= 61 | 62 | for arg 63 | do 64 | if test -n "$eat"; then 65 | eat= 66 | else 67 | case $1 in 68 | -o) 69 | # configure might choose to run compile as `compile cc -o foo foo.c'. 70 | # So we strip `-o arg' only if arg is an object. 71 | eat=1 72 | case $2 in 73 | *.o | *.obj) 74 | ofile=$2 75 | ;; 76 | *) 77 | set x "$@" -o "$2" 78 | shift 79 | ;; 80 | esac 81 | ;; 82 | *.c) 83 | cfile=$1 84 | set x "$@" "$1" 85 | shift 86 | ;; 87 | *) 88 | set x "$@" "$1" 89 | shift 90 | ;; 91 | esac 92 | fi 93 | shift 94 | done 95 | 96 | if test -z "$ofile" || test -z "$cfile"; then 97 | # If no `-o' option was seen then we might have been invoked from a 98 | # pattern rule where we don't need one. That is ok -- this is a 99 | # normal compilation that the losing compiler can handle. If no 100 | # `.c' file was seen then we are probably linking. That is also 101 | # ok. 102 | exec "$@" 103 | fi 104 | 105 | # Name of file we expect compiler to create. 106 | cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` 107 | 108 | # Create the lock directory. 109 | # Note: use `[/.-]' here to ensure that we don't use the same name 110 | # that we are using for the .o file. Also, base the name on the expected 111 | # object file name, since that is what matters with a parallel build. 112 | lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d 113 | while true; do 114 | if mkdir "$lockdir" >/dev/null 2>&1; then 115 | break 116 | fi 117 | sleep 1 118 | done 119 | # FIXME: race condition here if user kills between mkdir and trap. 120 | trap "rmdir '$lockdir'; exit 1" 1 2 15 121 | 122 | # Run the compile. 123 | "$@" 124 | ret=$? 125 | 126 | if test -f "$cofile"; then 127 | mv "$cofile" "$ofile" 128 | elif test -f "${cofile}bj"; then 129 | mv "${cofile}bj" "$ofile" 130 | fi 131 | 132 | rmdir "$lockdir" 133 | exit $ret 134 | 135 | # Local Variables: 136 | # mode: shell-script 137 | # sh-indentation: 2 138 | # eval: (add-hook 'write-file-hooks 'time-stamp) 139 | # time-stamp-start: "scriptversion=" 140 | # time-stamp-format: "%:y-%02m-%02d.%02H" 141 | # time-stamp-end: "$" 142 | # End: 143 | -------------------------------------------------------------------------------- /deps/check-0.9.8/check.m4: -------------------------------------------------------------------------------- 1 | dnl AM_PATH_CHECK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) 2 | dnl Test for check, and define CHECK_CFLAGS and CHECK_LIBS 3 | dnl 4 | 5 | AC_DEFUN([AM_PATH_CHECK], 6 | [ 7 | AC_MSG_WARN([A@&t@M_PATH_CHECK() is deprecated]) 8 | AC_MSG_WARN([[use P@&t@KG_CHECK_MODULES([CHECK], [check >= 0.9.4]) instead]]) 9 | AC_ARG_WITH([check], 10 | [ --with-check=PATH prefix where check is installed [default=auto]]) 11 | 12 | min_check_version=ifelse([$1], ,0.8.2,$1) 13 | 14 | AC_MSG_CHECKING(for check - version >= $min_check_version) 15 | 16 | if test x$with_check = xno; then 17 | AC_MSG_RESULT(disabled) 18 | ifelse([$3], , AC_MSG_ERROR([disabling check is not supported]), [$3]) 19 | else 20 | if test "x$with_check" != x; then 21 | CHECK_CFLAGS="-I$with_check/include" 22 | CHECK_LIBS="-L$with_check/lib -lcheck" 23 | else 24 | CHECK_CFLAGS="" 25 | CHECK_LIBS="-lcheck" 26 | fi 27 | 28 | ac_save_CFLAGS="$CFLAGS" 29 | ac_save_LIBS="$LIBS" 30 | 31 | CFLAGS="$CFLAGS $CHECK_CFLAGS" 32 | LIBS="$CHECK_LIBS $LIBS" 33 | 34 | rm -f conf.check-test 35 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT([]) 36 | #include 37 | 38 | int main () 39 | { 40 | int major, minor, micro; 41 | char *tmp_version; 42 | 43 | system ("touch conf.check-test"); 44 | 45 | /* HP/UX 9 (%@#!) writes to sscanf strings */ 46 | tmp_version = strdup("$min_check_version"); 47 | if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { 48 | printf("%s, bad version string\n", "$min_check_version"); 49 | return 1; 50 | } 51 | 52 | if ((CHECK_MAJOR_VERSION != check_major_version) || 53 | (CHECK_MINOR_VERSION != check_minor_version) || 54 | (CHECK_MICRO_VERSION != check_micro_version)) 55 | { 56 | printf("\n*** The check header file (version %d.%d.%d) does not match\n", 57 | CHECK_MAJOR_VERSION, CHECK_MINOR_VERSION, CHECK_MICRO_VERSION); 58 | printf("*** the check library (version %d.%d.%d).\n", 59 | check_major_version, check_minor_version, check_micro_version); 60 | return 1; 61 | } 62 | 63 | if ((check_major_version > major) || 64 | ((check_major_version == major) && (check_minor_version > minor)) || 65 | ((check_major_version == major) && (check_minor_version == minor) && (check_micro_version >= micro))) 66 | { 67 | return 0; 68 | } 69 | else 70 | { 71 | printf("\n*** An old version of check (%d.%d.%d) was found.\n", 72 | check_major_version, check_minor_version, check_micro_version); 73 | printf("*** You need a version of check being at least %d.%d.%d.\n", major, minor, micro); 74 | printf("***\n"); 75 | printf("*** If you have already installed a sufficiently new version, this error\n"); 76 | printf("*** probably means that the wrong copy of the check library and header\n"); 77 | printf("*** file is being found. Rerun configure with the --with-check=PATH option\n"); 78 | printf("*** to specify the prefix where the correct version was installed.\n"); 79 | } 80 | 81 | return 1; 82 | } 83 | ])],, no_check=yes, [echo $ac_n "cross compiling; assumed OK... $ac_c"]) 84 | 85 | CFLAGS="$ac_save_CFLAGS" 86 | LIBS="$ac_save_LIBS" 87 | 88 | if test "x$no_check" = x ; then 89 | AC_MSG_RESULT(yes) 90 | ifelse([$2], , :, [$2]) 91 | else 92 | AC_MSG_RESULT(no) 93 | if test -f conf.check-test ; then 94 | : 95 | else 96 | echo "*** Could not run check test program, checking why..." 97 | CFLAGS="$CFLAGS $CHECK_CFLAGS" 98 | LIBS="$CHECK_LIBS $LIBS" 99 | AC_TRY_LINK([ 100 | #include 101 | #include 102 | 103 | #include 104 | ], , [ echo "*** The test program compiled, but did not run. This usually means" 105 | echo "*** that the run-time linker is not finding check. You'll need to set your" 106 | echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" 107 | echo "*** to the installed location Also, make sure you have run ldconfig if that" 108 | echo "*** is required on your system" 109 | echo "***" 110 | echo "*** If you have an old version installed, it is best to remove it, although" 111 | echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], 112 | [ echo "*** The test program failed to compile or link. See the file config.log for" 113 | echo "*** the exact error that occured." ]) 114 | 115 | CFLAGS="$ac_save_CFLAGS" 116 | LIBS="$ac_save_LIBS" 117 | fi 118 | 119 | CHECK_CFLAGS="" 120 | CHECK_LIBS="" 121 | 122 | rm -f conf.check-test 123 | ifelse([$3], , AC_MSG_ERROR([check not found]), [$3]) 124 | fi 125 | 126 | AC_SUBST(CHECK_CFLAGS) 127 | AC_SUBST(CHECK_LIBS) 128 | 129 | rm -f conf.check-test 130 | 131 | fi 132 | ]) 133 | -------------------------------------------------------------------------------- /deps/check-0.9.8/check.pc: -------------------------------------------------------------------------------- 1 | prefix=/usr/local 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: Check 7 | Description: A unit test framework for C 8 | URL: http://check.sourceforge.net 9 | Version: 0.9.8 10 | Libs: -L${libdir} -lcheck 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /deps/check-0.9.8/check.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: Check 7 | Description: A unit test framework for C 8 | URL: http://check.sourceforge.net 9 | Version: @VERSION@ 10 | Libs: -L${libdir} -lcheck 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | info_TEXINFOS = check.texi 4 | check_TEXINFOS = fdl.texi 5 | 6 | ## we need to include several diffs as we evolve the example in the 7 | ## tutorial. this means we'll generate them from the example source. 8 | 9 | $(srcdir)/check.texi: money.1-2.h.diff \ 10 | money.1-3.c.diff \ 11 | money.3-4.c.diff \ 12 | money.4-5.c.diff \ 13 | money.5-6.c.diff \ 14 | check_money.1-2.c.diff \ 15 | check_money.2-3.c.diff \ 16 | check_money.3-6.c.diff \ 17 | check_money.6-7.c.diff 18 | 19 | eg_root = $(top_srcdir)/doc/example 20 | eg_src = $(eg_root)/src 21 | eg_tests = $(eg_root)/tests 22 | 23 | ## now a rule for each diff. the redundancy here can probably be 24 | ## parameterized, but I don't know how. if you know, please tell us! 25 | 26 | # diff returns 1 if there is a difference, but we don't want make to 27 | # think that means there is an error 28 | money.1-2.h.diff: $(eg_src)/money.1.h $(eg_src)/money.2.h 29 | cd $(eg_root); \ 30 | diff -u src/money.1.h src/money.2.h > @abs_builddir@/$@ || test $$? -eq 1; \ 31 | cd -; 32 | 33 | money.1-3.c.diff: $(eg_src)/money.1.c $(eg_src)/money.3.c 34 | cd $(eg_root); \ 35 | diff -u src/money.1.c src/money.3.c > @abs_builddir@/$@ || test $$? -eq 1; \ 36 | cd -; 37 | 38 | money.3-4.c.diff: $(eg_src)/money.3.c $(eg_src)/money.4.c 39 | cd $(eg_root); \ 40 | diff -u src/money.3.c src/money.4.c > @abs_builddir@/$@ || test $$? -eq 1; \ 41 | cd -; 42 | 43 | money.4-5.c.diff: $(eg_src)/money.4.c $(eg_src)/money.5.c 44 | cd $(eg_root); \ 45 | diff -u src/money.4.c src/money.5.c > @abs_builddir@/$@ || test $$? -eq 1; \ 46 | cd -; 47 | 48 | money.5-6.c.diff: $(eg_src)/money.5.c $(eg_src)/money.6.c 49 | cd $(eg_root); \ 50 | diff -u src/money.5.c src/money.6.c > @abs_builddir@/$@ || test $$? -eq 1; \ 51 | cd -; 52 | 53 | check_money.1-2.c.diff: $(eg_tests)/check_money.1.c $(eg_tests)/check_money.2.c 54 | cd $(eg_root); \ 55 | diff -u tests/check_money.1.c tests/check_money.2.c > @abs_builddir@/$@ || test $$? -eq 1; \ 56 | cd -; 57 | 58 | check_money.2-3.c.diff: $(eg_tests)/check_money.2.c $(eg_tests)/check_money.3.c 59 | cd $(eg_root); \ 60 | diff -u tests/check_money.2.c tests/check_money.3.c > @abs_builddir@/$@ || test $$? -eq 1; \ 61 | cd -; 62 | 63 | check_money.3-6.c.diff: $(eg_tests)/check_money.3.c $(eg_tests)/check_money.6.c 64 | cd $(eg_root); \ 65 | diff -u tests/check_money.3.c tests/check_money.6.c > @abs_builddir@/$@ || test $$? -eq 1; \ 66 | cd -; 67 | 68 | check_money.6-7.c.diff: $(eg_tests)/check_money.6.c $(eg_tests)/check_money.7.c 69 | cd $(eg_root); \ 70 | diff -u tests/check_money.6.c tests/check_money.7.c > @abs_builddir@/$@ || test $$? -eq 1; \ 71 | cd -; 72 | 73 | # explicitly list every file in the example. 74 | 75 | example_docs = example/Makefile.am \ 76 | example/README \ 77 | example/configure.ac 78 | 79 | example_src_docs = example/src/Makefile.am \ 80 | example/src/main.c \ 81 | example/src/money.c \ 82 | example/src/money.h \ 83 | example/src/money.1.h \ 84 | example/src/money.2.h \ 85 | example/src/money.1.c \ 86 | example/src/money.3.c \ 87 | example/src/money.4.c \ 88 | example/src/money.5.c \ 89 | example/src/money.6.c 90 | 91 | example_tests_docs = example/tests/Makefile.am \ 92 | example/tests/check_money.c \ 93 | example/tests/check_money.1.c \ 94 | example/tests/check_money.2.c \ 95 | example/tests/check_money.3.c \ 96 | example/tests/check_money.6.c \ 97 | example/tests/check_money.7.c 98 | 99 | ## what to clean 100 | 101 | CLEANFILES = *~ *.diff 102 | 103 | ## what to distribute 104 | 105 | EXTRA_DIST = $(example_docs) \ 106 | $(example_src_docs) \ 107 | $(example_tests_docs) 108 | 109 | ## what to install 110 | 111 | docdir = $(datadir)/doc/$(PACKAGE) 112 | 113 | # install money example 114 | 115 | exampledir = $(docdir)/example 116 | example_DATA = $(example_docs) 117 | 118 | examplesrcdir = $(docdir)/example/src 119 | examplesrc_DATA = $(example_src_docs) 120 | 121 | exampletestsdir = $(docdir)/example/tests 122 | exampletests_DATA = $(example_tests_docs) 123 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | SUBDIRS = src . tests -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/README: -------------------------------------------------------------------------------- 1 | This is the "money example" from the Check tutorial. 2 | 3 | You need the following programs installed on your system: 4 | -- Autoconf 2.59 5 | -- Automake 1.9.6 6 | -- Libtool 1.5.22 7 | -- Check 0.9.3 8 | 9 | Somewhat earlier versions of these programs might work. 10 | 11 | Then, do as follows: 12 | 13 | $ autoreconf --install 14 | $ ./configure 15 | $ make 16 | $ make check 17 | 18 | Don't do "make install" unless you want to install the money example. 19 | 20 | money.c and money.h are built as a library. src/main.c:main() is a 21 | client of libmoney.la, just as tests/check_money.c:main() is a client 22 | of libmoney.la 23 | 24 | Please send bug reports to check-devel AT lists.sourceforge.net. 25 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/configure.ac: -------------------------------------------------------------------------------- 1 | # Process this file with autoconf to produce a configure script. 2 | 3 | # Prelude. 4 | AC_PREREQ([2.59]) 5 | AC_INIT([Money], [0.3], [check-devel AT lists.sourceforge.net]) 6 | 7 | # unique source file --- primitive safety check 8 | AC_CONFIG_SRCDIR([src/money.c]) 9 | 10 | # place to put some extra build scripts installed 11 | AC_CONFIG_AUX_DIR([build-aux]) 12 | 13 | # fairly severe build strictness 14 | # change foreign to gnu or gnits to comply with gnu standards 15 | AM_INIT_AUTOMAKE([-Wall -Werror foreign 1.9.6]) 16 | 17 | # Checks for programs. 18 | AC_PROG_CC 19 | AC_PROG_LIBTOOL 20 | 21 | # Checks for libraries. 22 | 23 | # This macro is defined in check.m4 and tests if check.h and 24 | # libcheck.a are installed in your system. It sets CHECK_CFLAGS and 25 | # CHECK_LIBS accordingly. 26 | # AM_PATH_CHECK([MINIMUM-VERSION, 27 | # [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) 28 | AM_PATH_CHECK() 29 | 30 | # Checks for header files. 31 | AC_HEADER_STDC 32 | AC_CHECK_HEADERS([stdlib.h]) 33 | 34 | # Checks for typedefs, structures, and compiler characteristics. 35 | 36 | # Checks for library functions. 37 | AC_FUNC_MALLOC 38 | 39 | # Output files 40 | AC_CONFIG_HEADERS([config.h]) 41 | 42 | AC_CONFIG_FILES([Makefile 43 | src/Makefile 44 | tests/Makefile]) 45 | 46 | AC_OUTPUT 47 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/src/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | lib_LTLIBRARIES = libmoney.la 4 | libmoney_la_SOURCES = money.c money.h 5 | 6 | bin_PROGRAMS = main 7 | main_SOURCES = main.c 8 | main_LDADD = libmoney.la 9 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/src/main.c: -------------------------------------------------------------------------------- 1 | #include "money.h" 2 | 3 | /* only main should be in this file, to make all other functions in 4 | the prograble testable by Check. in order to test main(), use a 5 | whole program testing framework like Autotest. 6 | */ 7 | 8 | int 9 | main (void) 10 | { 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/src/money.1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armon/hlld/a7b035ff305a48335c8a3c39d6617ce5ffc1f980/deps/check-0.9.8/doc/example/src/money.1.c -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/src/money.1.h: -------------------------------------------------------------------------------- 1 | #ifndef MONEY_H 2 | #define MONEY_H 3 | 4 | #endif /* MONEY_H */ 5 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/src/money.2.h: -------------------------------------------------------------------------------- 1 | #ifndef MONEY_H 2 | #define MONEY_H 3 | 4 | typedef struct Money Money; 5 | 6 | Money *money_create (int amount, char *currency); 7 | int money_amount (Money * m); 8 | char *money_currency (Money * m); 9 | void money_free (Money * m); 10 | 11 | #endif /* MONEY_H */ 12 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/src/money.3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "money.h" 3 | 4 | Money * 5 | money_create (int amount, char *currency) 6 | { 7 | return NULL; 8 | } 9 | 10 | int 11 | money_amount (Money * m) 12 | { 13 | return 0; 14 | } 15 | 16 | char * 17 | money_currency (Money * m) 18 | { 19 | return NULL; 20 | } 21 | 22 | void 23 | money_free (Money * m) 24 | { 25 | return; 26 | } 27 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/src/money.4.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "money.h" 3 | 4 | struct Money 5 | { 6 | int amount; 7 | }; 8 | 9 | Money * 10 | money_create (int amount, char *currency) 11 | { 12 | return NULL; 13 | } 14 | 15 | int 16 | money_amount (Money * m) 17 | { 18 | return m->amount; 19 | } 20 | 21 | char * 22 | money_currency (Money * m) 23 | { 24 | return NULL; 25 | } 26 | 27 | void 28 | money_free (Money * m) 29 | { 30 | return; 31 | } 32 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/src/money.5.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "money.h" 3 | 4 | struct Money 5 | { 6 | int amount; 7 | char *currency; 8 | }; 9 | 10 | Money * 11 | money_create (int amount, char *currency) 12 | { 13 | Money *m = malloc (sizeof (Money)); 14 | if (m == NULL) 15 | { 16 | return NULL; 17 | } 18 | 19 | m->amount = amount; 20 | m->currency = currency; 21 | return m; 22 | } 23 | 24 | int 25 | money_amount (Money * m) 26 | { 27 | return m->amount; 28 | } 29 | 30 | char * 31 | money_currency (Money * m) 32 | { 33 | return m->currency; 34 | } 35 | 36 | void 37 | money_free (Money * m) 38 | { 39 | free (m); 40 | return; 41 | } 42 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/src/money.6.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "money.h" 3 | 4 | struct Money 5 | { 6 | int amount; 7 | char *currency; 8 | }; 9 | 10 | Money * 11 | money_create (int amount, char *currency) 12 | { 13 | if (amount < 0) 14 | { 15 | return NULL; 16 | } 17 | 18 | Money *m = malloc (sizeof (Money)); 19 | if (m == NULL) 20 | { 21 | return NULL; 22 | } 23 | 24 | m->amount = amount; 25 | m->currency = currency; 26 | return m; 27 | } 28 | 29 | int 30 | money_amount (Money * m) 31 | { 32 | return m->amount; 33 | } 34 | 35 | char * 36 | money_currency (Money * m) 37 | { 38 | return m->currency; 39 | } 40 | 41 | void 42 | money_free (Money * m) 43 | { 44 | free (m); 45 | return; 46 | } 47 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/src/money.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "money.h" 3 | 4 | struct Money 5 | { 6 | int amount; 7 | char *currency; 8 | }; 9 | 10 | Money * 11 | money_create (int amount, char *currency) 12 | { 13 | if (amount < 0) 14 | { 15 | return NULL; 16 | } 17 | 18 | Money *m = malloc (sizeof (Money)); 19 | if (m == NULL) 20 | { 21 | return NULL; 22 | } 23 | 24 | m->amount = amount; 25 | m->currency = currency; 26 | return m; 27 | } 28 | 29 | int 30 | money_amount (Money * m) 31 | { 32 | return m->amount; 33 | } 34 | 35 | char * 36 | money_currency (Money * m) 37 | { 38 | return m->currency; 39 | } 40 | 41 | void 42 | money_free (Money * m) 43 | { 44 | free (m); 45 | return; 46 | } 47 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/src/money.h: -------------------------------------------------------------------------------- 1 | #ifndef MONEY_H 2 | #define MONEY_H 3 | 4 | typedef struct Money Money; 5 | 6 | Money *money_create (int amount, char *currency); 7 | int money_amount (Money * m); 8 | char *money_currency (Money * m); 9 | void money_free (Money * m); 10 | 11 | #endif /* MONEY_H */ 12 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | TESTS = check_money 4 | check_PROGRAMS = check_money 5 | check_money_SOURCES = check_money.c $(top_builddir)/src/money.h 6 | check_money_CFLAGS = @CHECK_CFLAGS@ 7 | check_money_LDADD = $(top_builddir)/src/libmoney.la @CHECK_LIBS@ 8 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/tests/check_money.1.c: -------------------------------------------------------------------------------- 1 | int 2 | main (void) 3 | { 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/tests/check_money.2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../src/money.h" 3 | 4 | START_TEST (test_money_create) 5 | { 6 | Money *m; 7 | m = money_create (5, "USD"); 8 | fail_unless (money_amount (m) == 5, 9 | "Amount not set correctly on creation"); 10 | fail_unless (strcmp (money_currency (m), "USD") == 0, 11 | "Currency not set correctly on creation"); 12 | money_free (m); 13 | } 14 | END_TEST 15 | 16 | int 17 | main (void) 18 | { 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/tests/check_money.3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../src/money.h" 4 | 5 | START_TEST (test_money_create) 6 | { 7 | Money *m; 8 | m = money_create (5, "USD"); 9 | fail_unless (money_amount (m) == 5, 10 | "Amount not set correctly on creation"); 11 | fail_unless (strcmp (money_currency (m), "USD") == 0, 12 | "Currency not set correctly on creation"); 13 | money_free (m); 14 | } 15 | END_TEST 16 | 17 | Suite * 18 | money_suite (void) 19 | { 20 | Suite *s = suite_create ("Money"); 21 | 22 | /* Core test case */ 23 | TCase *tc_core = tcase_create ("Core"); 24 | tcase_add_test (tc_core, test_money_create); 25 | suite_add_tcase (s, tc_core); 26 | 27 | return s; 28 | } 29 | 30 | int 31 | main (void) 32 | { 33 | int number_failed; 34 | Suite *s = money_suite (); 35 | SRunner *sr = srunner_create (s); 36 | srunner_run_all (sr, CK_NORMAL); 37 | number_failed = srunner_ntests_failed (sr); 38 | srunner_free (sr); 39 | return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 40 | } 41 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/tests/check_money.6.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../src/money.h" 4 | 5 | START_TEST (test_money_create) 6 | { 7 | Money *m; 8 | m = money_create (5, "USD"); 9 | fail_unless (money_amount (m) == 5, 10 | "Amount not set correctly on creation"); 11 | fail_unless (strcmp (money_currency (m), "USD") == 0, 12 | "Currency not set correctly on creation"); 13 | money_free (m); 14 | } 15 | END_TEST 16 | 17 | START_TEST (test_money_create_neg) 18 | { 19 | Money *m = money_create (-1, "USD"); 20 | fail_unless (m == NULL, 21 | "NULL should be returned on attempt to create with " 22 | "a negative amount"); 23 | } 24 | END_TEST 25 | 26 | START_TEST (test_money_create_zero) 27 | { 28 | Money *m = money_create (0, "USD"); 29 | fail_unless (money_amount (m) == 0, 30 | "Zero is a valid amount of money"); 31 | } 32 | END_TEST 33 | 34 | Suite * 35 | money_suite (void) 36 | { 37 | Suite *s = suite_create ("Money"); 38 | 39 | /* Core test case */ 40 | TCase *tc_core = tcase_create ("Core"); 41 | tcase_add_test (tc_core, test_money_create); 42 | suite_add_tcase (s, tc_core); 43 | 44 | /* Limits test case */ 45 | TCase *tc_limits = tcase_create ("Limits"); 46 | tcase_add_test (tc_limits, test_money_create_neg); 47 | tcase_add_test (tc_limits, test_money_create_zero); 48 | suite_add_tcase (s, tc_limits); 49 | 50 | return s; 51 | } 52 | 53 | int 54 | main (void) 55 | { 56 | int number_failed; 57 | Suite *s = money_suite (); 58 | SRunner *sr = srunner_create (s); 59 | srunner_run_all (sr, CK_NORMAL); 60 | number_failed = srunner_ntests_failed (sr); 61 | srunner_free (sr); 62 | return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 63 | } 64 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/tests/check_money.7.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../src/money.h" 4 | 5 | Money *five_dollars; 6 | 7 | void 8 | setup (void) 9 | { 10 | five_dollars = money_create (5, "USD"); 11 | } 12 | 13 | void 14 | teardown (void) 15 | { 16 | money_free (five_dollars); 17 | } 18 | 19 | START_TEST (test_money_create) 20 | { 21 | fail_unless (money_amount (five_dollars) == 5, 22 | "Amount not set correctly on creation"); 23 | fail_unless (strcmp (money_currency (five_dollars), "USD") == 0, 24 | "Currency not set correctly on creation"); 25 | } 26 | END_TEST 27 | 28 | START_TEST (test_money_create_neg) 29 | { 30 | Money *m = money_create (-1, "USD"); 31 | fail_unless (m == NULL, 32 | "NULL should be returned on attempt to create with " 33 | "a negative amount"); 34 | } 35 | END_TEST 36 | 37 | START_TEST (test_money_create_zero) 38 | { 39 | Money *m = money_create (0, "USD"); 40 | fail_unless (money_amount (m) == 0, 41 | "Zero is a valid amount of money"); 42 | } 43 | END_TEST 44 | 45 | Suite * 46 | money_suite (void) 47 | { 48 | Suite *s = suite_create ("Money"); 49 | 50 | /* Core test case */ 51 | TCase *tc_core = tcase_create ("Core"); 52 | tcase_add_checked_fixture (tc_core, setup, teardown); 53 | tcase_add_test (tc_core, test_money_create); 54 | suite_add_tcase (s, tc_core); 55 | 56 | /* Limits test case */ 57 | TCase *tc_limits = tcase_create ("Limits"); 58 | tcase_add_test (tc_limits, test_money_create_neg); 59 | tcase_add_test (tc_limits, test_money_create_zero); 60 | suite_add_tcase (s, tc_limits); 61 | 62 | return s; 63 | } 64 | 65 | int 66 | main (void) 67 | { 68 | int number_failed; 69 | Suite *s = money_suite (); 70 | SRunner *sr = srunner_create (s); 71 | srunner_run_all (sr, CK_NORMAL); 72 | number_failed = srunner_ntests_failed (sr); 73 | srunner_free (sr); 74 | return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 75 | } 76 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/example/tests/check_money.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../src/money.h" 4 | 5 | Money *five_dollars; 6 | 7 | void 8 | setup (void) 9 | { 10 | five_dollars = money_create (5, "USD"); 11 | } 12 | 13 | void 14 | teardown (void) 15 | { 16 | money_free (five_dollars); 17 | } 18 | 19 | START_TEST (test_money_create) 20 | { 21 | fail_unless (money_amount (five_dollars) == 5, 22 | "Amount not set correctly on creation"); 23 | fail_unless (strcmp (money_currency (five_dollars), "USD") == 0, 24 | "Currency not set correctly on creation"); 25 | } 26 | END_TEST 27 | 28 | START_TEST (test_money_create_neg) 29 | { 30 | Money *m = money_create (-1, "USD"); 31 | fail_unless (m == NULL, 32 | "NULL should be returned on attempt to create with " 33 | "a negative amount"); 34 | } 35 | END_TEST 36 | 37 | START_TEST (test_money_create_zero) 38 | { 39 | Money *m = money_create (0, "USD"); 40 | fail_unless (money_amount (m) == 0, 41 | "Zero is a valid amount of money"); 42 | } 43 | END_TEST 44 | 45 | Suite * 46 | money_suite (void) 47 | { 48 | Suite *s = suite_create ("Money"); 49 | 50 | /* Core test case */ 51 | TCase *tc_core = tcase_create ("Core"); 52 | tcase_add_checked_fixture (tc_core, setup, teardown); 53 | tcase_add_test (tc_core, test_money_create); 54 | suite_add_tcase (s, tc_core); 55 | 56 | /* Limits test case */ 57 | TCase *tc_limits = tcase_create ("Limits"); 58 | tcase_add_test (tc_limits, test_money_create_neg); 59 | tcase_add_test (tc_limits, test_money_create_zero); 60 | suite_add_tcase (s, tc_limits); 61 | 62 | return s; 63 | } 64 | 65 | int 66 | main (void) 67 | { 68 | int number_failed; 69 | Suite *s = money_suite (); 70 | SRunner *sr = srunner_create (s); 71 | srunner_run_all (sr, CK_NORMAL); 72 | number_failed = srunner_ntests_failed (sr); 73 | srunner_free (sr); 74 | return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 75 | } 76 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/stamp-vti: -------------------------------------------------------------------------------- 1 | @set UPDATED 23 September 2009 2 | @set UPDATED-MONTH September 2009 3 | @set EDITION 0.9.8 4 | @set VERSION 0.9.8 5 | -------------------------------------------------------------------------------- /deps/check-0.9.8/doc/version.texi: -------------------------------------------------------------------------------- 1 | @set UPDATED 23 September 2009 2 | @set UPDATED-MONTH September 2009 3 | @set EDITION 0.9.8 4 | @set VERSION 0.9.8 5 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/.deps/fileno.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/.deps/localtime_r.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/.deps/malloc.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/.deps/pipe.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/.deps/putenv.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/.deps/realloc.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/.deps/setenv.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/.deps/sleep.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/.deps/strdup.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/.deps/strsignal.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/.deps/unsetenv.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | noinst_LTLIBRARIES = libcompat.la 4 | libcompat_la_LDFLAGS = -no-undefined 5 | libcompat_la_SOURCES = libcompat.c libcompat.h 6 | libcompat_la_LIBADD = $(LTLIBOBJS) $(LTALLOCA) 7 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/fileno.c: -------------------------------------------------------------------------------- 1 | #include "libcompat.h" 2 | 3 | int fileno(FILE *stream CK_ATTRIBUTE_UNUSED) 4 | { 5 | assert (0); 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/libcompat.c: -------------------------------------------------------------------------------- 1 | #include "libcompat.h" 2 | 3 | /* silence warnings about an empty library */ 4 | void 5 | ck_do_nothing (void) 6 | { 7 | assert (0); 8 | } 9 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/libcompat.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBCOMPAT_H 2 | #define LIBCOMPAT_H 3 | 4 | #if HAVE_CONFIG_H 5 | #include 6 | #endif 7 | 8 | #if defined(__GNUC__) && defined(__GNUC_MINOR__) 9 | #define GCC_VERSION_AT_LEAST(major, minor) \ 10 | ((__GNUC__ > (major)) || \ 11 | (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) 12 | #else 13 | #define GCC_VERSION_AT_LEAST(major, minor) 0 14 | #endif 15 | 16 | #if GCC_VERSION_AT_LEAST(2,95) 17 | #define CK_ATTRIBUTE_UNUSED __attribute__ ((unused)) 18 | #else 19 | #define CK_ATTRIBUTE_UNUSED 20 | #endif /* GCC 2.95 */ 21 | 22 | /* defines size_t */ 23 | #include 24 | 25 | /* provides assert */ 26 | #include 27 | 28 | /* defines FILE */ 29 | #include 30 | 31 | /* provides localtime and struct tm */ 32 | #include 33 | #include 34 | 35 | /* declares fork(), _POSIX_VERSION. according to Autoconf.info, 36 | unistd.h defines _POSIX_VERSION if the system is POSIX-compliant, 37 | so we will use this as a test for all things uniquely provided by 38 | POSIX like sigaction() and fork() */ 39 | #ifdef HAVE_UNISTD_H 40 | #include 41 | #endif 42 | 43 | #ifdef HAVE_SYS_WAIT_H 44 | #include 45 | #endif 46 | 47 | /* declares pthread_create and friends */ 48 | #ifdef HAVE_PTHREAD 49 | #include 50 | #endif 51 | 52 | /* replacement functions for broken originals */ 53 | #if !HAVE_MALLOC 54 | void *rpl_malloc (size_t n); 55 | #endif /* !HAVE_MALLOC */ 56 | 57 | #if !HAVE_REALLOC 58 | void *rpl_realloc (void *p, size_t n); 59 | #endif /* !HAVE_REALLOC */ 60 | 61 | /* functions that may be undeclared */ 62 | #if !HAVE_DECL_FILENO 63 | int fileno (FILE *stream); 64 | #endif /* !HAVE_DECL_FILENO */ 65 | 66 | #if !HAVE_DECL_LOCALTIME_R 67 | struct tm *localtime_r (const time_t *clock, struct tm *result); 68 | #endif /* !HAVE_DECL_LOCALTIME_R */ 69 | 70 | #if !HAVE_DECL_PIPE 71 | int pipe (int *fildes); 72 | #endif /* !HAVE_DECL_PIPE */ 73 | 74 | #if !HAVE_DECL_PUTENV 75 | int putenv (const char *string); 76 | #endif /* !HAVE_DECL_PUTENV */ 77 | 78 | #if !HAVE_DECL_SETENV 79 | int setenv (const char *name, const char *value, int overwrite); 80 | #endif /* !HAVE_DECL_SETENV */ 81 | 82 | /* our setenv implementation is currently broken */ 83 | #if !HAVE_SETENV 84 | #define HAVE_WORKING_SETENV 0 85 | #else 86 | #define HAVE_WORKING_SETENV 1 87 | #endif 88 | 89 | #if !HAVE_DECL_SLEEP 90 | unsigned int sleep (unsigned int seconds); 91 | #endif /* !HAVE_DECL_SLEEP */ 92 | 93 | #if !HAVE_DECL_STRDUP 94 | char *strdup (const char *str); 95 | #endif /* !HAVE_DECL_STRDUP */ 96 | 97 | #if !HAVE_DECL_STRSIGNAL 98 | const char *strsignal (int sig); 99 | #endif /* !HAVE_DECL_STRSIGNAL */ 100 | 101 | #if !HAVE_DECL_UNSETENV 102 | void unsetenv (const char *name); 103 | #endif /* !HAVE_DECL_UNSETENV */ 104 | 105 | /* silence warnings about an empty library */ 106 | void ck_do_nothing (void); 107 | 108 | #endif /* !LIBCOMPAT_H */ 109 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/localtime_r.c: -------------------------------------------------------------------------------- 1 | #include "libcompat.h" 2 | 3 | struct tm * 4 | localtime_r (const time_t *clock, struct tm *result) 5 | { 6 | struct tm *now = localtime (clock); 7 | if (now == NULL) 8 | { 9 | return NULL; 10 | } 11 | else 12 | { 13 | *result = *now; 14 | } 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/malloc.c: -------------------------------------------------------------------------------- 1 | /* AC_FUNC_MALLOC in configure defines malloc to rpl_malloc if 2 | malloc (0) is NULL to provide GNU compatibility */ 3 | 4 | #include "libcompat.h" 5 | 6 | /* malloc has been defined to rpl_malloc, so first undo that */ 7 | #undef malloc 8 | 9 | /* this gives us the real malloc to use below */ 10 | void *malloc (size_t n); 11 | 12 | /* force malloc(0) to return a valid pointer */ 13 | void * 14 | rpl_malloc (size_t n) 15 | { 16 | if (n == 0) 17 | n = 1; 18 | return malloc (n); 19 | } 20 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/pipe.c: -------------------------------------------------------------------------------- 1 | #include "libcompat.h" 2 | 3 | int 4 | pipe (int *fildes CK_ATTRIBUTE_UNUSED) 5 | { 6 | assert (0); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/putenv.c: -------------------------------------------------------------------------------- 1 | #include "libcompat.h" 2 | 3 | int 4 | putenv (const char *string CK_ATTRIBUTE_UNUSED); 5 | { 6 | assert (0); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/realloc.c: -------------------------------------------------------------------------------- 1 | /* AC_FUNC_REALLOC in configure defines realloc to rpl_realloc if 2 | realloc (p, 0) or realloc (0, n) is NULL to provide GNU 3 | compatibility */ 4 | 5 | #include "libcompat.h" 6 | 7 | /* realloc has been defined to rpl_realloc, so first undo that */ 8 | #undef realloc 9 | 10 | /* this gives us the real realloc to use below */ 11 | void *realloc (void *p, size_t n); 12 | 13 | /* force realloc(p, 0) and realloc (NULL, n) to return a valid pointer */ 14 | void * 15 | rpl_realloc (void *p, size_t n) 16 | { 17 | if (n == 0) 18 | n = 1; 19 | if (p == 0) 20 | return malloc (n); 21 | return realloc (p, n); 22 | } 23 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/setenv.c: -------------------------------------------------------------------------------- 1 | #include "libcompat.h" 2 | 3 | int 4 | setenv (const char *name CK_ATTRIBUTE_UNUSED, const char *value CK_ATTRIBUTE_UNUSED, int overwrite CK_ATTRIBUTE_UNUSED) 5 | { 6 | assert (0); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/sleep.c: -------------------------------------------------------------------------------- 1 | #include "libcompat.h" 2 | 3 | unsigned int 4 | sleep (unsigned int seconds CK_ATTRIBUTE_UNUSED) 5 | { 6 | assert (0); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/strdup.c: -------------------------------------------------------------------------------- 1 | #include "libcompat.h" 2 | 3 | char * 4 | strdup (const char *str CK_ATTRIBUTE_UNUSED) 5 | { 6 | assert (0); 7 | return NULL; 8 | } 9 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/strsignal.c: -------------------------------------------------------------------------------- 1 | #include "libcompat.h" 2 | 3 | const char * 4 | strsignal (int sig) 5 | { 6 | static char signame[40]; 7 | sprintf(signame, "SIG #%d", sig); 8 | return signame; 9 | } 10 | -------------------------------------------------------------------------------- /deps/check-0.9.8/lib/unsetenv.c: -------------------------------------------------------------------------------- 1 | #include "libcompat.h" 2 | 3 | void 4 | unsetenv (const char *name CK_ATTRIBUTE_UNUSED) 5 | { 6 | assert (0); 7 | } 8 | -------------------------------------------------------------------------------- /deps/check-0.9.8/m4/ax_c_check_flag.m4: -------------------------------------------------------------------------------- 1 | ##### http://autoconf-archive.cryp.to/ax_c_check_flag.html 2 | # 3 | # SYNOPSIS 4 | # 5 | # AX_C_CHECK_FLAG(FLAG-TO-CHECK,[PROLOGUE],[BODY],[ACTION-IF-SUCCESS],[ACTION-IF-FAILURE]) 6 | # 7 | # DESCRIPTION 8 | # 9 | # This macro tests if the C compiler supports the flag FLAG-TO-CHECK. 10 | # If successfull execute ACTION-IF-SUCCESS otherwise 11 | # ACTION-IF-FAILURE. PROLOGUE and BODY are optional and should be 12 | # used as in AC_LANG_PROGRAM macro. 13 | # 14 | # This code is inspired from KDE_CHECK_COMPILER_FLAG macro. Thanks to 15 | # Bogdan Drozdowski for testing and bug fixes. 16 | # 17 | # LAST MODIFICATION 18 | # 19 | # 2007-11-26 20 | # 21 | # COPYLEFT 22 | # 23 | # Copyright (c) 2007 Francesco Salvestrini 24 | # 25 | # This program is free software; you can redistribute it and/or 26 | # modify it under the terms of the GNU General Public License as 27 | # published by the Free Software Foundation; either version 2 of the 28 | # License, or (at your option) any later version. 29 | # 30 | # This program is distributed in the hope that it will be useful, but 31 | # WITHOUT ANY WARRANTY; without even the implied warranty of 32 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 33 | # General Public License for more details. 34 | # 35 | # You should have received a copy of the GNU General Public License 36 | # along with this program; if not, write to the Free Software 37 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 38 | # 02111-1307, USA. 39 | # 40 | # As a special exception, the respective Autoconf Macro's copyright 41 | # owner gives unlimited permission to copy, distribute and modify the 42 | # configure scripts that are the output of Autoconf when processing 43 | # the Macro. You need not follow the terms of the GNU General Public 44 | # License when using or distributing such scripts, even though 45 | # portions of the text of the Macro appear in them. The GNU General 46 | # Public License (GPL) does govern all other use of the material that 47 | # constitutes the Autoconf Macro. 48 | # 49 | # This special exception to the GPL applies to versions of the 50 | # Autoconf Macro released by the Autoconf Macro Archive. When you 51 | # make and distribute a modified version of the Autoconf Macro, you 52 | # may extend this special exception to the GPL to apply to your 53 | # modified version as well. 54 | 55 | AC_DEFUN([AX_C_CHECK_FLAG],[ 56 | AC_PREREQ([2.61]) 57 | AC_REQUIRE([AC_PROG_CC]) 58 | AC_REQUIRE([AC_PROG_SED]) 59 | 60 | flag=`echo "$1" | $SED 'y% .=/+-(){}<>:*,%_______________%'` 61 | 62 | AC_CACHE_CHECK([whether the C compiler accepts the $1 flag], 63 | [ax_cv_c_check_flag_$flag],[ 64 | 65 | AC_LANG_PUSH([C]) 66 | 67 | save_CFLAGS="$CFLAGS" 68 | CFLAGS="$CFLAGS $1" 69 | AC_COMPILE_IFELSE([ 70 | AC_LANG_PROGRAM([$2],[$3]) 71 | ],[ 72 | eval "ax_cv_c_check_flag_$flag=yes" 73 | ],[ 74 | eval "ax_cv_c_check_flag_$flag=no" 75 | ]) 76 | 77 | CFLAGS="$save_CFLAGS" 78 | 79 | AC_LANG_POP 80 | 81 | ]) 82 | 83 | AS_IF([eval "test \"`echo '$ax_cv_c_check_flag_'$flag`\" = yes"],[ 84 | : 85 | $4 86 | ],[ 87 | : 88 | $5 89 | ]) 90 | ]) 91 | -------------------------------------------------------------------------------- /deps/check-0.9.8/m4/ltsugar.m4: -------------------------------------------------------------------------------- 1 | # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. 4 | # Written by Gary V. Vaughan, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # serial 6 ltsugar.m4 11 | 12 | # This is to help aclocal find these macros, as it can't see m4_define. 13 | AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 14 | 15 | 16 | # lt_join(SEP, ARG1, [ARG2...]) 17 | # ----------------------------- 18 | # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 19 | # associated separator. 20 | # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 21 | # versions in m4sugar had bugs. 22 | m4_define([lt_join], 23 | [m4_if([$#], [1], [], 24 | [$#], [2], [[$2]], 25 | [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 26 | m4_define([_lt_join], 27 | [m4_if([$#$2], [2], [], 28 | [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 29 | 30 | 31 | # lt_car(LIST) 32 | # lt_cdr(LIST) 33 | # ------------ 34 | # Manipulate m4 lists. 35 | # These macros are necessary as long as will still need to support 36 | # Autoconf-2.59 which quotes differently. 37 | m4_define([lt_car], [[$1]]) 38 | m4_define([lt_cdr], 39 | [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 40 | [$#], 1, [], 41 | [m4_dquote(m4_shift($@))])]) 42 | m4_define([lt_unquote], $1) 43 | 44 | 45 | # lt_append(MACRO-NAME, STRING, [SEPARATOR]) 46 | # ------------------------------------------ 47 | # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. 48 | # Note that neither SEPARATOR nor STRING are expanded; they are appended 49 | # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 50 | # No SEPARATOR is output if MACRO-NAME was previously undefined (different 51 | # than defined and empty). 52 | # 53 | # This macro is needed until we can rely on Autoconf 2.62, since earlier 54 | # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 55 | m4_define([lt_append], 56 | [m4_define([$1], 57 | m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 58 | 59 | 60 | 61 | # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 62 | # ---------------------------------------------------------- 63 | # Produce a SEP delimited list of all paired combinations of elements of 64 | # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 65 | # has the form PREFIXmINFIXSUFFIXn. 66 | # Needed until we can rely on m4_combine added in Autoconf 2.62. 67 | m4_define([lt_combine], 68 | [m4_if(m4_eval([$# > 3]), [1], 69 | [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 70 | [[m4_foreach([_Lt_prefix], [$2], 71 | [m4_foreach([_Lt_suffix], 72 | ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 73 | [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 74 | 75 | 76 | # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 77 | # ----------------------------------------------------------------------- 78 | # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 79 | # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 80 | m4_define([lt_if_append_uniq], 81 | [m4_ifdef([$1], 82 | [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 83 | [lt_append([$1], [$2], [$3])$4], 84 | [$5])], 85 | [lt_append([$1], [$2], [$3])$4])]) 86 | 87 | 88 | # lt_dict_add(DICT, KEY, VALUE) 89 | # ----------------------------- 90 | m4_define([lt_dict_add], 91 | [m4_define([$1($2)], [$3])]) 92 | 93 | 94 | # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 95 | # -------------------------------------------- 96 | m4_define([lt_dict_add_subkey], 97 | [m4_define([$1($2:$3)], [$4])]) 98 | 99 | 100 | # lt_dict_fetch(DICT, KEY, [SUBKEY]) 101 | # ---------------------------------- 102 | m4_define([lt_dict_fetch], 103 | [m4_ifval([$3], 104 | m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 105 | m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 106 | 107 | 108 | # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 109 | # ----------------------------------------------------------------- 110 | m4_define([lt_if_dict_fetch], 111 | [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 112 | [$5], 113 | [$6])]) 114 | 115 | 116 | # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 117 | # -------------------------------------------------------------- 118 | m4_define([lt_dict_filter], 119 | [m4_if([$5], [], [], 120 | [lt_join(m4_quote(m4_default([$4], [[, ]])), 121 | lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 122 | [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 123 | ]) 124 | -------------------------------------------------------------------------------- /deps/check-0.9.8/m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # Generated from ltversion.in. 11 | 12 | # serial 3012 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.2.6]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3012]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.2.6' 20 | macro_revision='1.3012' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /deps/check-0.9.8/src/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | lib_LTLIBRARIES = libcheck.la 4 | noinst_LTLIBRARIES = libcheckinternal.la 5 | 6 | include_HEADERS = check.h 7 | 8 | EXTRA_DIST = check.h.in 9 | 10 | AM_CFLAGS = @GCOV_CFLAGS@ @PTHREAD_CFLAGS@ 11 | 12 | CFILES =\ 13 | check.c \ 14 | check_error.c \ 15 | check_list.c \ 16 | check_log.c \ 17 | check_msg.c \ 18 | check_pack.c \ 19 | check_print.c \ 20 | check_run.c \ 21 | check_str.c 22 | 23 | HFILES =\ 24 | check.h \ 25 | check_error.h \ 26 | check_impl.h \ 27 | check_list.h \ 28 | check_log.h \ 29 | check_msg.h \ 30 | check_pack.h \ 31 | check_print.h \ 32 | check_str.h 33 | 34 | 35 | EXPORT_SYM = exported.sym 36 | $(EXPORT_SYM): check.h.in 37 | sed -n -e 's/^..*CK_EXPORT[[:space:]][[:space:]]*\([[:alnum:]_][[:alnum:]_]*\)..*$$/\1/p' @top_srcdir@/src/check.h.in > $@ 38 | 39 | libcheck_la_DEPENDENCIES= $(EXPORT_SYM) 40 | libcheck_la_LDFLAGS = -no-undefined -export-symbols $(EXPORT_SYM) 41 | libcheck_la_SOURCES = $(CFILES) $(HFILES) 42 | libcheck_la_LIBADD = @GCOV_LIBS@ @PTHREAD_LIBS@ $(top_builddir)/lib/libcompat.la 43 | 44 | libcheckinternal_la_LDFLAGS = -no-undefined 45 | libcheckinternal_la_SOURCES = $(CFILES) $(HFILES) 46 | libcheckinternal_la_LIBADD = @GCOV_LIBS@ @PTHREAD_LIBS@ $(top_builddir)/lib/libcompat.la 47 | 48 | CLEANFILES = *~ *.gcno $(EXPORT_SYM) 49 | 50 | LCOV_INPUT = $(CFILES:%.c=.libs/%.gcda) 51 | LCOV_OUTPUT = lcov.info 52 | LCOV_HTML = lcov_html 53 | LCOV_LCOV = @LCOV@ 54 | LCOV_GENHTML = @GENHTML@ 55 | 56 | lcov: $(LCOV_HTML) 57 | 58 | $(LCOV_INPUT): libcheck.la libcheckinternal.la 59 | @$(MAKE) -C $(top_builddir)/tests check 60 | 61 | $(LCOV_OUTPUT): $(LCOV_INPUT) 62 | $(LCOV_LCOV) --capture --directory . --base-directory . --output-file $@ 63 | 64 | $(LCOV_HTML): $(LCOV_OUTPUT) 65 | -$(RM) -r $@ 66 | LANG=C $(LCOV_GENHTML) --output-directory $@ --title "Check Code Coverage" --show-details $< 67 | @echo "Point a web browser at $(LCOV_HTML)/index.html to see results." 68 | 69 | clean-local: lcov-clean 70 | 71 | .PHONY: lcov-clean 72 | lcov-clean: 73 | -$(RM) -r $(LCOV_HTML) $(LCOV_OUTPUT) 74 | -------------------------------------------------------------------------------- /deps/check-0.9.8/src/check_error.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Check: a unit test framework for C 3 | * Copyright (C) 2001, 2002 Arien Malec 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #include "../lib/libcompat.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "check_error.h" 30 | 31 | 32 | /* FIXME: including a colon at the end is a bad way to indicate an error */ 33 | void eprintf (const char *fmt, const char *file, int line, ...) 34 | { 35 | va_list args; 36 | fflush(stderr); 37 | 38 | fprintf(stderr,"%s:%d: ",file,line); 39 | va_start(args, line); 40 | vfprintf(stderr, fmt, args); 41 | va_end(args); 42 | 43 | /*include system error information if format ends in colon */ 44 | if (fmt[0] != '\0' && fmt[strlen(fmt)-1] == ':') 45 | fprintf(stderr, " %s", strerror(errno)); 46 | fprintf(stderr, "\n"); 47 | 48 | exit(2); 49 | } 50 | 51 | void *emalloc (size_t n) 52 | { 53 | void *p; 54 | p = malloc(n); 55 | if (p == NULL) 56 | eprintf("malloc of %u bytes failed:", __FILE__, __LINE__ - 2, n); 57 | return p; 58 | } 59 | 60 | void *erealloc (void * ptr, size_t n) 61 | { 62 | void *p; 63 | p = realloc (ptr, n); 64 | if (p == NULL) 65 | eprintf("realloc of %u bytes failed:", __FILE__, __LINE__ - 2, n); 66 | return p; 67 | } 68 | -------------------------------------------------------------------------------- /deps/check-0.9.8/src/check_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Check: a unit test framework for C 3 | * Copyright (C) 2001, 2002 Arien Malec 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef ERROR_H 22 | #define ERROR_H 23 | 24 | /* Include stdlib.h beforehand */ 25 | 26 | /* Print error message and die 27 | If fmt ends in colon, include system error information */ 28 | void eprintf (const char *fmt, const char *file, int line,...); 29 | /* malloc or die */ 30 | void *emalloc(size_t n); 31 | void *erealloc(void *, size_t n); 32 | 33 | #endif /*ERROR_H*/ 34 | -------------------------------------------------------------------------------- /deps/check-0.9.8/src/check_impl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Check: a unit test framework for C 3 | * Copyright (C) 2001,2002 Arien Malec 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef CHECK_IMPL_H 22 | #define CHECK_IMPL_H 23 | 24 | 25 | /* This header should be included by any module that needs 26 | to know the implementation details of the check structures 27 | Include stdio.h & list.h before this header 28 | */ 29 | 30 | typedef struct TF { 31 | TFun fn; 32 | int loop_start; 33 | int loop_end; 34 | const char *name; 35 | int signal; 36 | unsigned char allowed_exit_value; 37 | } TF; 38 | 39 | struct Suite { 40 | const char *name; 41 | List *tclst; /* List of test cases */ 42 | }; 43 | 44 | typedef struct Fixture 45 | { 46 | int ischecked; 47 | SFun fun; 48 | } Fixture; 49 | 50 | struct TCase { 51 | const char *name; 52 | int timeout; 53 | List *tflst; /* list of test functions */ 54 | List *unch_sflst; 55 | List *unch_tflst; 56 | List *ch_sflst; 57 | List *ch_tflst; 58 | }; 59 | 60 | typedef struct TestStats { 61 | int n_checked; 62 | int n_failed; 63 | int n_errors; 64 | } TestStats; 65 | 66 | struct TestResult { 67 | enum test_result rtype; /* Type of result */ 68 | enum ck_result_ctx ctx; /* When the result occurred */ 69 | char *file; /* File where the test occured */ 70 | int line; /* Line number where the test occurred */ 71 | int iter; /* The iteration value for looping tests */ 72 | const char *tcname; /* Test case that generated the result */ 73 | const char *tname; /* Test that generated the result */ 74 | char *msg; /* Failure message */ 75 | }; 76 | 77 | TestResult *tr_create(void); 78 | void tr_reset(TestResult *tr); 79 | 80 | enum cl_event { 81 | CLINITLOG_SR, 82 | CLENDLOG_SR, 83 | CLSTART_SR, 84 | CLSTART_S, 85 | CLEND_SR, 86 | CLEND_S, 87 | CLSTART_T, /* A test case is about to run */ 88 | CLEND_T 89 | }; 90 | 91 | typedef void (*LFun) (SRunner *, FILE*, enum print_output, 92 | void *, enum cl_event); 93 | 94 | typedef struct Log { 95 | FILE *lfile; 96 | LFun lfun; 97 | int close; 98 | enum print_output mode; 99 | } Log; 100 | 101 | struct SRunner { 102 | List *slst; /* List of Suite objects */ 103 | TestStats *stats; /* Run statistics */ 104 | List *resultlst; /* List of unit test results */ 105 | const char *log_fname; /* name of log file */ 106 | const char *xml_fname; /* name of xml output file */ 107 | List *loglst; /* list of Log objects */ 108 | enum fork_status fstat; /* controls if suites are forked or not 109 | NOTE: Don't use this value directly, 110 | instead use srunner_fork_status */ 111 | }; 112 | 113 | 114 | void set_fork_status(enum fork_status fstat); 115 | enum fork_status cur_fork_status (void); 116 | 117 | #endif /* CHECK_IMPL_H */ 118 | -------------------------------------------------------------------------------- /deps/check-0.9.8/src/check_list.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Check: a unit test framework for C 3 | * Copyright (C) 2001, 2002 Arien Malec 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #include "../lib/libcompat.h" 22 | 23 | #include 24 | #include 25 | 26 | #include "check_list.h" 27 | #include "check_error.h" 28 | 29 | 30 | enum { 31 | LINIT = 1, 32 | LGROW = 2 33 | }; 34 | 35 | struct List { 36 | int n_elts; 37 | int max_elts; 38 | int current; /* pointer to the current node */ 39 | int last; /* pointer to the node before END */ 40 | const void **data; 41 | }; 42 | 43 | static void maybe_grow (List *lp) 44 | { 45 | if (lp->n_elts >= lp->max_elts) { 46 | lp->max_elts *= LGROW; 47 | lp->data = erealloc (lp->data, lp->max_elts * sizeof(lp->data[0])); 48 | } 49 | } 50 | 51 | List *check_list_create (void) 52 | { 53 | List *lp; 54 | lp = emalloc (sizeof(List)); 55 | lp->n_elts = 0; 56 | lp->max_elts = LINIT; 57 | lp->data = emalloc(sizeof(lp->data[0]) * LINIT); 58 | lp->current = lp->last = -1; 59 | return lp; 60 | } 61 | 62 | void list_add_front (List *lp, const void *val) 63 | { 64 | if (lp == NULL) 65 | return; 66 | maybe_grow(lp); 67 | memmove(lp->data + 1, lp->data, lp->n_elts * sizeof lp->data[0]); 68 | lp->last++; 69 | lp->n_elts++; 70 | lp->current = 0; 71 | lp->data[lp->current] = val; 72 | } 73 | 74 | void list_add_end (List *lp, const void *val) 75 | { 76 | if (lp == NULL) 77 | return; 78 | maybe_grow(lp); 79 | lp->last++; 80 | lp->n_elts++; 81 | lp->current = lp->last; 82 | lp->data[lp->current] = val; 83 | } 84 | 85 | int list_at_end (List *lp) 86 | { 87 | if (lp->current == -1) 88 | return 1; 89 | else 90 | return (lp->current > lp->last); 91 | } 92 | 93 | void list_front (List *lp) 94 | { 95 | if (lp->current == -1) 96 | return; 97 | lp->current = 0; 98 | } 99 | 100 | 101 | void list_free (List *lp) 102 | { 103 | if (lp == NULL) 104 | return; 105 | 106 | free(lp->data); 107 | free (lp); 108 | } 109 | 110 | void *list_val (List *lp) 111 | { 112 | if (lp == NULL) 113 | return NULL; 114 | if (lp->current == -1 || lp->current > lp->last) 115 | return NULL; 116 | 117 | return (void*) lp->data[lp->current]; 118 | } 119 | 120 | void list_advance (List *lp) 121 | { 122 | if (lp == NULL) 123 | return; 124 | if (list_at_end(lp)) 125 | return; 126 | lp->current++; 127 | } 128 | 129 | 130 | void list_apply (List *lp, void (*fp) (void *)) 131 | { 132 | if (lp == NULL || fp == NULL) 133 | return; 134 | 135 | for (list_front(lp); !list_at_end(lp); list_advance(lp)) 136 | fp (list_val(lp)); 137 | 138 | } 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /deps/check-0.9.8/src/check_list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Check: a unit test framework for C 3 | * Copyright (C) 2001, 2002 Arien Malec 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef CHECK_LIST_H 22 | #define CHECK_LIST_H 23 | 24 | typedef struct List List; 25 | 26 | /* Create an empty list */ 27 | List * check_list_create (void); 28 | 29 | /* Is list at end? */ 30 | int list_at_end (List * lp); 31 | 32 | /* Position list at front */ 33 | void list_front(List *lp); 34 | 35 | /* Add a value to the front of the list, 36 | positioning newly added value as current value. 37 | More expensive than list_add_end, as it uses memmove. */ 38 | void list_add_front (List *lp, const void *val); 39 | 40 | /* Add a value to the end of the list, 41 | positioning newly added value as current value */ 42 | void list_add_end (List *lp, const void *val); 43 | 44 | /* Give the value of the current node */ 45 | void *list_val (List * lp); 46 | 47 | /* Position the list at the next node */ 48 | void list_advance (List * lp); 49 | 50 | /* Free a list, but don't free values */ 51 | void list_free (List * lp); 52 | 53 | void list_apply (List *lp, void (*fp) (void *)); 54 | 55 | 56 | #endif /* CHECK_LIST_H */ 57 | -------------------------------------------------------------------------------- /deps/check-0.9.8/src/check_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Check: a unit test framework for C 3 | * Copyright (C) 2001,2002 Arien Malec 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef CHECK_LOG_H 22 | #define CHECK_LOG_H 23 | 24 | void log_srunner_start (SRunner *sr); 25 | void log_srunner_end (SRunner *sr); 26 | void log_suite_start (SRunner *sr, Suite *s); 27 | void log_suite_end (SRunner *sr, Suite *s); 28 | void log_test_end (SRunner *sr, TestResult *tr); 29 | void log_test_start (SRunner *sr, TCase *tc, TF *tfun); 30 | 31 | void stdout_lfun (SRunner *sr, FILE *file, enum print_output, 32 | void *obj, enum cl_event evt); 33 | 34 | void lfile_lfun (SRunner *sr, FILE *file, enum print_output, 35 | void *obj, enum cl_event evt); 36 | 37 | void xml_lfun (SRunner *sr, FILE *file, enum print_output, 38 | void *obj, enum cl_event evt); 39 | 40 | void subunit_lfun (SRunner *sr, FILE *file, enum print_output, 41 | void *obj, enum cl_event evt); 42 | 43 | void srunner_register_lfun (SRunner *sr, FILE *lfile, int close, 44 | LFun lfun, enum print_output); 45 | 46 | FILE *srunner_open_lfile (SRunner *sr); 47 | FILE *srunner_open_xmlfile (SRunner *sr); 48 | void srunner_init_logging (SRunner *sr, enum print_output print_mode); 49 | void srunner_end_logging (SRunner *sr); 50 | 51 | #endif /* CHECK_LOG_H */ 52 | -------------------------------------------------------------------------------- /deps/check-0.9.8/src/check_msg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Check: a unit test framework for C 3 | * Copyright (C) 2001, 2002 Arien Malec 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef CHECK_MSG_NEW_H 22 | #define CHECK_MSG_NEW_H 23 | 24 | 25 | /* Functions implementing messaging during test runs */ 26 | 27 | void send_failure_info(const char *msg); 28 | void send_loc_info(const char *file, int line); 29 | void send_ctx_info(enum ck_result_ctx ctx); 30 | 31 | TestResult *receive_test_result(int waserror); 32 | 33 | void setup_messaging(void); 34 | void teardown_messaging(void); 35 | 36 | #endif /*CHECK_MSG_NEW_H */ 37 | -------------------------------------------------------------------------------- /deps/check-0.9.8/src/check_pack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Check: a unit test framework for C 3 | * Copyright (C) 2001, 2002 Arien Malec 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef CHECK_PACK_H 22 | #define CHECK_PACK_H 23 | 24 | 25 | enum ck_msg_type { 26 | CK_MSG_CTX, 27 | CK_MSG_FAIL, 28 | CK_MSG_LOC, 29 | CK_MSG_LAST 30 | }; 31 | 32 | typedef struct CtxMsg 33 | { 34 | enum ck_result_ctx ctx; 35 | } CtxMsg; 36 | 37 | typedef struct LocMsg 38 | { 39 | int line; 40 | char *file; 41 | } LocMsg; 42 | 43 | typedef struct FailMsg 44 | { 45 | char *msg; 46 | } FailMsg; 47 | 48 | typedef union 49 | { 50 | CtxMsg ctx_msg; 51 | FailMsg fail_msg; 52 | LocMsg loc_msg; 53 | } CheckMsg; 54 | 55 | typedef struct RcvMsg 56 | { 57 | enum ck_result_ctx lastctx; 58 | enum ck_result_ctx failctx; 59 | char *fixture_file; 60 | int fixture_line; 61 | char *test_file; 62 | int test_line; 63 | char *msg; 64 | } RcvMsg; 65 | 66 | void rcvmsg_free (RcvMsg *rmsg); 67 | 68 | 69 | int pack (enum ck_msg_type type, char **buf, CheckMsg *msg); 70 | int upack (char *buf, CheckMsg *msg, enum ck_msg_type *type); 71 | 72 | void ppack (int fdes, enum ck_msg_type type, CheckMsg *msg); 73 | RcvMsg *punpack (int fdes); 74 | 75 | 76 | #endif /*CHECK_PACK_H */ 77 | -------------------------------------------------------------------------------- /deps/check-0.9.8/src/check_print.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Check: a unit test framework for C 3 | * Copyright (C) 2001, 2002 Arien Malec 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #include "../lib/libcompat.h" 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "check.h" 28 | #include "check_list.h" 29 | #include "check_impl.h" 30 | #include "check_str.h" 31 | #include "check_print.h" 32 | 33 | static void srunner_fprint_summary (FILE *file, SRunner *sr, 34 | enum print_output print_mode); 35 | static void srunner_fprint_results (FILE *file, SRunner *sr, 36 | enum print_output print_mode); 37 | 38 | 39 | void srunner_print (SRunner *sr, enum print_output print_mode) 40 | { 41 | srunner_fprint (stdout, sr, print_mode); 42 | } 43 | 44 | void srunner_fprint (FILE *file, SRunner *sr, enum print_output print_mode) 45 | { 46 | if (print_mode == CK_ENV) { 47 | print_mode = get_env_printmode(); 48 | } 49 | 50 | srunner_fprint_summary (file, sr, print_mode); 51 | srunner_fprint_results (file, sr, print_mode); 52 | } 53 | 54 | static void srunner_fprint_summary (FILE *file, SRunner *sr, 55 | enum print_output print_mode) 56 | { 57 | #if ENABLE_SUBUNIT 58 | if (print_mode == CK_SUBUNIT) 59 | return; 60 | #endif 61 | 62 | if (print_mode >= CK_MINIMAL) { 63 | char *str; 64 | 65 | str = sr_stat_str (sr); 66 | fprintf (file, "%s\n", str); 67 | free(str); 68 | } 69 | return; 70 | } 71 | 72 | static void srunner_fprint_results (FILE *file, SRunner *sr, 73 | enum print_output print_mode) 74 | { 75 | List *resultlst; 76 | 77 | #if ENABLE_SUBUNIT 78 | if (print_mode == CK_SUBUNIT) 79 | return; 80 | #endif 81 | 82 | resultlst = sr->resultlst; 83 | 84 | for (list_front(resultlst); !list_at_end(resultlst); list_advance(resultlst)) { 85 | TestResult *tr = list_val(resultlst); 86 | tr_fprint (file, tr, print_mode); 87 | } 88 | return; 89 | } 90 | 91 | void tr_fprint (FILE *file, TestResult *tr, enum print_output print_mode) 92 | { 93 | if (print_mode == CK_ENV) { 94 | print_mode = get_env_printmode(); 95 | } 96 | 97 | if ((print_mode >= CK_VERBOSE && tr->rtype == CK_PASS) || 98 | (tr->rtype != CK_PASS && print_mode >= CK_NORMAL)) { 99 | char *trstr = tr_str (tr); 100 | fprintf (file,"%s\n", trstr); 101 | free(trstr); 102 | } 103 | } 104 | 105 | void tr_xmlprint (FILE *file, TestResult *tr, enum print_output print_mode CK_ATTRIBUTE_UNUSED) 106 | { 107 | char result[10]; 108 | char *path_name; 109 | char *file_name; 110 | char *slash; 111 | 112 | switch (tr->rtype) { 113 | case CK_PASS: 114 | strcpy(result, "success"); 115 | break; 116 | case CK_FAILURE: 117 | strcpy(result, "failure"); 118 | break; 119 | case CK_ERROR: 120 | strcpy(result, "error"); 121 | break; 122 | case CK_TEST_RESULT_INVALID: 123 | default: 124 | abort (); 125 | break; 126 | } 127 | 128 | slash = strrchr(tr->file, '/'); 129 | if (slash == NULL) { 130 | path_name = (char*)"."; 131 | file_name = tr->file; 132 | } else { 133 | path_name = strdup(tr->file); 134 | path_name[slash - tr->file] = 0; /* Terminate the temporary string. */ 135 | file_name = slash + 1; 136 | } 137 | 138 | 139 | fprintf(file, " \n", result); 140 | fprintf(file, " %s\n", path_name); 141 | fprintf(file, " %s:%d\n", file_name, tr->line); 142 | fprintf(file, " %s\n", tr->tname); 143 | fprintf(file, " %d\n", tr->iter); 144 | fprintf(file, " %s\n", tr->tcname); 145 | fprintf(file, " %s\n", tr->msg); 146 | fprintf(file, " \n"); 147 | 148 | if (slash != NULL) { 149 | free(path_name); 150 | } 151 | } 152 | 153 | enum print_output get_env_printmode (void) 154 | { 155 | char *env = getenv ("CK_VERBOSITY"); 156 | if (env == NULL) 157 | return CK_NORMAL; 158 | if (strcmp (env, "silent") == 0) 159 | return CK_SILENT; 160 | if (strcmp (env, "minimal") == 0) 161 | return CK_MINIMAL; 162 | if (strcmp (env, "verbose") == 0) 163 | return CK_VERBOSE; 164 | return CK_NORMAL; 165 | } 166 | -------------------------------------------------------------------------------- /deps/check-0.9.8/src/check_print.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Check: a unit test framework for C 3 | * Copyright (C) 2001, 2002 Arien Malec 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef CHECK_PRINT_H 22 | #define CHECK_PRINT_H 23 | 24 | void tr_fprint (FILE *file, TestResult *tr, enum print_output print_mode); 25 | void tr_xmlprint (FILE *file, TestResult *tr, enum print_output print_mode); 26 | void srunner_fprint (FILE *file, SRunner *sr, enum print_output print_mode); 27 | enum print_output get_env_printmode (void); 28 | 29 | 30 | #endif /* CHECK_PRINT_H */ 31 | -------------------------------------------------------------------------------- /deps/check-0.9.8/src/check_str.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Check: a unit test framework for C 3 | * Copyright (C) 2001, 2002 Arien Malec 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #include "../lib/libcompat.h" 22 | 23 | #include 24 | #include 25 | 26 | #include "check.h" 27 | #include "check_list.h" 28 | #include "check_error.h" 29 | #include "check_impl.h" 30 | #include "check_str.h" 31 | 32 | static const char *tr_type_str (TestResult *tr); 33 | static int percent_passed (TestStats *t); 34 | 35 | char *tr_str (TestResult *tr) 36 | { 37 | const char *exact_msg; 38 | char *rstr; 39 | 40 | exact_msg = (tr->rtype == CK_ERROR) ? "(after this point) ": ""; 41 | 42 | rstr = ck_strdup_printf ("%s:%d:%s:%s:%s:%d: %s%s", 43 | tr->file, tr->line, 44 | tr_type_str(tr), tr->tcname, tr->tname, tr->iter, 45 | exact_msg, tr->msg); 46 | 47 | return rstr; 48 | } 49 | 50 | char *tr_short_str (TestResult *tr) 51 | { 52 | const char *exact_msg; 53 | char *rstr; 54 | 55 | exact_msg = (tr->rtype == CK_ERROR) ? "(after this point) ": ""; 56 | 57 | rstr = ck_strdup_printf ("%s:%d: %s%s", 58 | tr->file, tr->line, 59 | exact_msg, tr->msg); 60 | 61 | return rstr; 62 | } 63 | 64 | char *sr_stat_str (SRunner *sr) 65 | { 66 | char *str; 67 | TestStats *ts; 68 | 69 | ts = sr->stats; 70 | 71 | str = ck_strdup_printf ("%d%%: Checks: %d, Failures: %d, Errors: %d", 72 | percent_passed (ts), ts->n_checked, ts->n_failed, 73 | ts->n_errors); 74 | 75 | return str; 76 | } 77 | 78 | char *ck_strdup_printf (const char *fmt, ...) 79 | { 80 | /* Guess we need no more than 100 bytes. */ 81 | int n, size = 100; 82 | char *p; 83 | va_list ap; 84 | 85 | p = emalloc (size); 86 | 87 | while (1) 88 | { 89 | /* Try to print in the allocated space. */ 90 | va_start(ap, fmt); 91 | n = vsnprintf (p, size, fmt, ap); 92 | va_end(ap); 93 | /* If that worked, return the string. */ 94 | if (n > -1 && n < size) 95 | return p; 96 | 97 | /* Else try again with more space. */ 98 | if (n > -1) /* C99 conform vsnprintf() */ 99 | size = n+1; /* precisely what is needed */ 100 | else /* glibc 2.0 */ 101 | size *= 2; /* twice the old size */ 102 | 103 | p = erealloc (p, size); 104 | } 105 | } 106 | 107 | static const char *tr_type_str (TestResult *tr) 108 | { 109 | const char *str = NULL; 110 | if (tr->ctx == CK_CTX_TEST) { 111 | if (tr->rtype == CK_PASS) 112 | str = "P"; 113 | else if (tr->rtype == CK_FAILURE) 114 | str = "F"; 115 | else if (tr->rtype == CK_ERROR) 116 | str = "E"; 117 | } else 118 | str = "S"; 119 | 120 | return str; 121 | } 122 | 123 | static int percent_passed (TestStats *t) 124 | { 125 | if (t->n_failed == 0 && t->n_errors == 0) 126 | return 100; 127 | else if (t->n_checked == 0) 128 | return 0; 129 | else 130 | return (int) ( (float) (t->n_checked - (t->n_failed + t->n_errors)) / 131 | (float) t->n_checked * 100); 132 | } 133 | -------------------------------------------------------------------------------- /deps/check-0.9.8/src/check_str.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Check: a unit test framework for C 3 | * Copyright (C) 2001, 2002 Arien Malec 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef CHECK_STR_H 22 | #define CHECK_STR_H 23 | 24 | /* Return a string representation of the given TestResult. Return 25 | value has been malloc'd, and must be freed by the caller */ 26 | char *tr_str (TestResult *tr); 27 | 28 | /* Return a string representation of the given TestResult message 29 | without the test id or result type. This is suitable for separate 30 | formatting of the test and the message. Return value has been 31 | malloc'd, and must be freed by the caller */ 32 | char *tr_short_str (TestResult *tr); 33 | 34 | /* Return a string representation of the given SRunner's run 35 | statistics (% passed, num run, passed, errors, failures). Return 36 | value has been malloc'd, and must be freed by the caller 37 | */ 38 | char *sr_stat_str (SRunner *sr); 39 | 40 | char *ck_strdup_printf (const char *fmt, ...); 41 | 42 | #endif /* CHECK_STR_H */ 43 | -------------------------------------------------------------------------------- /deps/check-0.9.8/stamp-h1: -------------------------------------------------------------------------------- 1 | timestamp for config.h 2 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/.deps/check_check-check_check_exit.Po: -------------------------------------------------------------------------------- 1 | check_check-check_check_exit.o: check_check_exit.c /usr/include/stdlib.h \ 2 | /usr/include/features.h /usr/include/x86_64-linux-gnu/bits/predefs.h \ 3 | /usr/include/x86_64-linux-gnu/sys/cdefs.h \ 4 | /usr/include/x86_64-linux-gnu/bits/wordsize.h \ 5 | /usr/include/x86_64-linux-gnu/gnu/stubs.h \ 6 | /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ 7 | /usr/lib/gcc/x86_64-linux-gnu/4.6/include/stddef.h \ 8 | /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/stdio.h \ 9 | /usr/include/x86_64-linux-gnu/bits/types.h \ 10 | /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \ 11 | /usr/include/_G_config.h /usr/include/wchar.h \ 12 | /usr/lib/gcc/x86_64-linux-gnu/4.6/include/stdarg.h \ 13 | /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ 14 | /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ 15 | /usr/include/x86_64-linux-gnu/bits/stdio.h \ 16 | /usr/include/x86_64-linux-gnu/bits/stdio2.h /usr/include/string.h \ 17 | /usr/include/x86_64-linux-gnu/bits/string.h \ 18 | /usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/endian.h \ 19 | /usr/include/x86_64-linux-gnu/bits/endian.h \ 20 | /usr/include/x86_64-linux-gnu/bits/string3.h /usr/include/unistd.h \ 21 | /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ 22 | /usr/include/x86_64-linux-gnu/bits/confname.h \ 23 | /usr/include/x86_64-linux-gnu/bits/unistd.h ../src/check.h \ 24 | /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \ 25 | check_check.h 26 | 27 | /usr/include/stdlib.h: 28 | 29 | /usr/include/features.h: 30 | 31 | /usr/include/x86_64-linux-gnu/bits/predefs.h: 32 | 33 | /usr/include/x86_64-linux-gnu/sys/cdefs.h: 34 | 35 | /usr/include/x86_64-linux-gnu/bits/wordsize.h: 36 | 37 | /usr/include/x86_64-linux-gnu/gnu/stubs.h: 38 | 39 | /usr/include/x86_64-linux-gnu/gnu/stubs-64.h: 40 | 41 | /usr/lib/gcc/x86_64-linux-gnu/4.6/include/stddef.h: 42 | 43 | /usr/include/x86_64-linux-gnu/bits/stdlib.h: 44 | 45 | /usr/include/stdio.h: 46 | 47 | /usr/include/x86_64-linux-gnu/bits/types.h: 48 | 49 | /usr/include/x86_64-linux-gnu/bits/typesizes.h: 50 | 51 | /usr/include/libio.h: 52 | 53 | /usr/include/_G_config.h: 54 | 55 | /usr/include/wchar.h: 56 | 57 | /usr/lib/gcc/x86_64-linux-gnu/4.6/include/stdarg.h: 58 | 59 | /usr/include/x86_64-linux-gnu/bits/stdio_lim.h: 60 | 61 | /usr/include/x86_64-linux-gnu/bits/sys_errlist.h: 62 | 63 | /usr/include/x86_64-linux-gnu/bits/stdio.h: 64 | 65 | /usr/include/x86_64-linux-gnu/bits/stdio2.h: 66 | 67 | /usr/include/string.h: 68 | 69 | /usr/include/x86_64-linux-gnu/bits/string.h: 70 | 71 | /usr/include/x86_64-linux-gnu/bits/string2.h: 72 | 73 | /usr/include/endian.h: 74 | 75 | /usr/include/x86_64-linux-gnu/bits/endian.h: 76 | 77 | /usr/include/x86_64-linux-gnu/bits/string3.h: 78 | 79 | /usr/include/unistd.h: 80 | 81 | /usr/include/x86_64-linux-gnu/bits/posix_opt.h: 82 | 83 | /usr/include/x86_64-linux-gnu/bits/confname.h: 84 | 85 | /usr/include/x86_64-linux-gnu/bits/unistd.h: 86 | 87 | ../src/check.h: 88 | 89 | /usr/include/x86_64-linux-gnu/sys/types.h: 90 | 91 | /usr/include/time.h: 92 | 93 | check_check.h: 94 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | TESTS = \ 4 | check_check_export \ 5 | check_check \ 6 | test_output.sh \ 7 | test_xml_output.sh \ 8 | test_log_output.sh 9 | 10 | # check_thread_stress is kind of slow. 11 | # add this line back to TESTS to enable check_thread_stress 12 | # check_thread_stress \ 13 | # 14 | # uncomment if check_thread_stress enabled 15 | # XFAIL_TESTS = \ 16 | # check_thread_stress 17 | 18 | noinst_PROGRAMS = \ 19 | check_check_export \ 20 | check_check \ 21 | check_stress \ 22 | check_thread_stress \ 23 | ex_output \ 24 | ex_xml_output \ 25 | ex_log_output 26 | 27 | EXTRA_DIST = test_output.sh test_log_output.sh test_vars.in test_xml_output.sh 28 | 29 | if NO_TIMEOUT_TESTS 30 | check_check_CFLAGS = -DTIMEOUT_TESTS_ENABLED=0 31 | check_check_export_CFLAGS = -DTIMEOUT_TESTS_ENABLED=0 32 | endif 33 | 34 | check_check_export_SOURCES = \ 35 | check_check.h \ 36 | check_check_sub.c \ 37 | check_check_master.c \ 38 | check_check_log.c \ 39 | check_check_fork.c \ 40 | check_check_export_main.c 41 | check_check_export_LDADD = $(top_builddir)/src/libcheck.la $(top_builddir)/lib/libcompat.la 42 | 43 | check_check_SOURCES = \ 44 | check_check.h \ 45 | check_list.c \ 46 | check_check_sub.c \ 47 | check_check_master.c \ 48 | check_check_msg.c \ 49 | check_check_log.c \ 50 | check_check_log_internal.c \ 51 | check_check_limit.c \ 52 | check_check_fork.c \ 53 | check_check_fixture.c \ 54 | check_check_pack.c \ 55 | check_check_exit.c \ 56 | check_check_main.c 57 | check_check_LDADD = $(top_builddir)/src/libcheckinternal.la $(top_builddir)/lib/libcompat.la 58 | 59 | check_stress_SOURCES = check_stress.c 60 | check_stress_LDADD = $(top_builddir)/src/libcheck.la $(top_builddir)/lib/libcompat.la 61 | 62 | check_thread_stress_SOURCES = check_thread_stress.c 63 | check_thread_stress_LDADD = $(top_builddir)/src/libcheck.la $(top_builddir)/lib/libcompat.la @PTHREAD_LIBS@ 64 | check_thread_stress_CFLAGS = @PTHREAD_CFLAGS@ 65 | 66 | ex_output_SOURCES = ex_output.c 67 | ex_output_LDADD = $(top_builddir)/src/libcheck.la $(top_builddir)/lib/libcompat.la 68 | 69 | ex_log_output_SOURCES = ex_log_output.c 70 | ex_log_output_LDADD = $(top_builddir)/src/libcheck.la $(top_builddir)/lib/libcompat.la 71 | 72 | ex_xml_output_SOURCES = ex_xml_output.c 73 | ex_xml_output_LDADD = $(top_builddir)/src/libcheck.la $(top_builddir)/lib/libcompat.la 74 | 75 | AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src 76 | 77 | CLEANFILES = *~ *.log *.xml test_logfile 78 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/check_check.h: -------------------------------------------------------------------------------- 1 | #ifndef CHECK_CHECK_H 2 | #define CHECK_CHECK_H 3 | 4 | #ifndef TIMEOUT_TESTS_ENABLED 5 | #define TIMEOUT_TESTS_ENABLED 1 6 | #endif 7 | 8 | int sub_nfailed; 9 | int sub_ntests; 10 | 11 | void fork_setup (void); 12 | void fork_teardown (void); 13 | void setup_fixture(void); 14 | void teardown_fixture (void); 15 | void setup (void); 16 | void cleanup (void); 17 | Suite *make_sub_suite(void); 18 | Suite *make_sub2_suite(void); 19 | Suite *make_master_suite(void); 20 | Suite *make_list_suite(void); 21 | Suite *make_msg_suite(void); 22 | Suite *make_log_suite(void); 23 | Suite *make_log_internal_suite(void); 24 | Suite *make_limit_suite(void); 25 | Suite *make_fork_suite(void); 26 | Suite *make_fixture_suite(void); 27 | Suite *make_pack_suite(void); 28 | Suite *make_exit_suite(void); 29 | 30 | extern int master_tests_lineno[]; 31 | void init_master_tests_lineno(void); 32 | 33 | #endif /* CHECK_CHECK_H */ 34 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/check_check_exit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "check.h" 7 | #include "check_check.h" 8 | 9 | START_TEST(test_early_exit_normal) 10 | { 11 | exit(0); 12 | fail("Should've exitted..."); 13 | } 14 | END_TEST 15 | 16 | START_TEST(test_early_exit_with_allowed_error) 17 | { 18 | exit(-1); 19 | fail("Should've exitted..."); 20 | } 21 | END_TEST 22 | 23 | START_TEST(loop_early_exit_normal) 24 | { 25 | exit(0); 26 | fail("Should've exitted..."); 27 | } 28 | END_TEST 29 | 30 | START_TEST(loop_early_exit_allowed_exit) 31 | { 32 | exit(-2); 33 | fail("Should've exitted..."); 34 | } 35 | END_TEST 36 | 37 | Suite *make_exit_suite(void) 38 | { 39 | Suite *s; 40 | TCase *tc; 41 | 42 | s = suite_create("Exit"); 43 | tc = tcase_create("Core"); 44 | 45 | suite_add_tcase (s, tc); 46 | tcase_add_test(tc,test_early_exit_normal); 47 | tcase_add_exit_test(tc,test_early_exit_with_allowed_error,-1); 48 | tcase_add_loop_test(tc,loop_early_exit_normal,0,5); 49 | tcase_add_loop_exit_test(tc,loop_early_exit_allowed_exit,-2,0,5); 50 | return s; 51 | } 52 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/check_check_export_main.c: -------------------------------------------------------------------------------- 1 | #include "../lib/libcompat.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include "check_check.h" 7 | 8 | int main (void) 9 | { 10 | int n; 11 | SRunner *sr; 12 | 13 | fork_setup(); 14 | setup(); 15 | sr = srunner_create (make_master_suite()); 16 | srunner_add_suite(sr, make_log_suite()); 17 | srunner_add_suite(sr, make_fork_suite()); 18 | 19 | printf ("Ran %d tests in subordinate suite\n", sub_ntests); 20 | srunner_run_all (sr, CK_VERBOSE); 21 | cleanup(); 22 | fork_teardown(); 23 | n = srunner_ntests_failed(sr); 24 | srunner_free(sr); 25 | return (n == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 26 | } 27 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/check_check_fork.c: -------------------------------------------------------------------------------- 1 | #include "../lib/libcompat.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include "check_check.h" 7 | 8 | 9 | static int counter; 10 | static pid_t mypid; 11 | 12 | static void fork_sub_setup (void) 13 | { 14 | counter = 0; 15 | mypid = getpid(); 16 | } 17 | 18 | START_TEST(test_inc) 19 | { 20 | counter++; 21 | } 22 | END_TEST 23 | 24 | START_TEST(test_nofork_sideeffects) 25 | { 26 | fail_unless(counter == 1, 27 | "Side effects not seen across tests"); 28 | } 29 | END_TEST 30 | 31 | START_TEST(test_nofork_pid) 32 | { 33 | fail_unless(mypid == getpid(), 34 | "Unit test is in a different adresss space from setup code"); 35 | } 36 | END_TEST 37 | 38 | static Suite *make_fork_sub_suite (void) 39 | { 40 | 41 | Suite *s; 42 | TCase *tc; 43 | 44 | s = suite_create("Fork Sub"); 45 | tc = tcase_create("Core"); 46 | 47 | suite_add_tcase (s, tc); 48 | tcase_add_unchecked_fixture(tc, fork_sub_setup,NULL); 49 | tcase_add_test(tc,test_inc); 50 | tcase_add_test(tc,test_nofork_sideeffects); 51 | tcase_add_test(tc,test_nofork_pid); 52 | 53 | return s; 54 | } 55 | 56 | static SRunner *fork_sr; 57 | static SRunner *fork_dummy_sr; 58 | 59 | void fork_setup (void) 60 | { 61 | fork_sr = srunner_create(make_fork_sub_suite()); 62 | fork_dummy_sr = srunner_create (make_fork_sub_suite()); 63 | srunner_set_fork_status(fork_sr,CK_NOFORK); 64 | srunner_run_all(fork_sr,CK_VERBOSE); 65 | } 66 | 67 | void fork_teardown (void) 68 | { 69 | srunner_free(fork_sr); 70 | } 71 | 72 | START_TEST(test_default_fork) 73 | { 74 | fail_unless(srunner_fork_status(fork_dummy_sr) == CK_FORK, 75 | "Default fork status not set correctly"); 76 | } 77 | END_TEST 78 | 79 | START_TEST(test_set_fork) 80 | { 81 | srunner_set_fork_status(fork_dummy_sr, CK_NOFORK); 82 | fail_unless(srunner_fork_status(fork_dummy_sr) == CK_NOFORK, 83 | "Fork status not changed correctly"); 84 | } 85 | END_TEST 86 | 87 | START_TEST(test_env) 88 | { 89 | putenv((char *) "CK_FORK=no"); 90 | fail_unless(srunner_fork_status(fork_dummy_sr) == CK_NOFORK, 91 | "Fork status does not obey environment variable"); 92 | } 93 | END_TEST 94 | 95 | START_TEST(test_env_and_set) 96 | { 97 | putenv((char *) "CK_FORK=no"); 98 | srunner_set_fork_status(fork_dummy_sr, CK_FORK); 99 | fail_unless(srunner_fork_status(fork_dummy_sr) == CK_FORK, 100 | "Explicit setting of fork status should override env"); 101 | } 102 | END_TEST 103 | 104 | 105 | START_TEST(test_nofork) 106 | { 107 | fail_unless(srunner_ntests_failed(fork_sr) == 0, 108 | "Errors on nofork test"); 109 | } 110 | END_TEST 111 | 112 | Suite *make_fork_suite(void) 113 | { 114 | Suite *s; 115 | TCase *tc; 116 | 117 | s = suite_create("Fork"); 118 | tc = tcase_create("Core"); 119 | 120 | suite_add_tcase(s, tc); 121 | tcase_add_test(tc,test_default_fork); 122 | tcase_add_test(tc,test_set_fork); 123 | tcase_add_test(tc,test_env); 124 | tcase_add_test(tc,test_env_and_set); 125 | tcase_add_test(tc,test_nofork); 126 | 127 | return s; 128 | } 129 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/check_check_limit.c: -------------------------------------------------------------------------------- 1 | #include "../lib/libcompat.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include "check_check.h" 7 | #include "check_str.h" 8 | 9 | 10 | static SRunner *sr; 11 | 12 | static void limit_setup (void) 13 | { 14 | Suite *s = suite_create("Empty"); 15 | sr = srunner_create(s); 16 | srunner_run_all(sr, CK_VERBOSE); 17 | } 18 | 19 | static void limit_teardown (void) 20 | { 21 | srunner_free(sr); 22 | } 23 | 24 | START_TEST(test_summary) 25 | { 26 | fail_unless(strcmp(sr_stat_str(sr), 27 | "100%: Checks: 0, Failures: 0, Errors: 0") == 0, 28 | "Bad statistics string for empty suite"); 29 | } 30 | END_TEST 31 | 32 | Suite *make_limit_suite (void) 33 | { 34 | Suite *s = suite_create("Limit"); 35 | TCase *tc = tcase_create("Empty"); 36 | 37 | tcase_add_test(tc,test_summary); 38 | tcase_add_unchecked_fixture(tc,limit_setup,limit_teardown); 39 | 40 | suite_add_tcase(s, tc); 41 | 42 | return s; 43 | } 44 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/check_check_log.c: -------------------------------------------------------------------------------- 1 | #include "../lib/libcompat.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "check_check.h" 8 | 9 | 10 | START_TEST(test_set_log) 11 | { 12 | Suite *s = suite_create("Suite"); 13 | SRunner *sr = srunner_create(s); 14 | 15 | srunner_set_log (sr, "test_log"); 16 | 17 | fail_unless (srunner_has_log (sr), "SRunner not logging"); 18 | fail_unless (strcmp(srunner_log_fname(sr), "test_log") == 0, 19 | "Bad file name returned"); 20 | } 21 | END_TEST 22 | 23 | START_TEST(test_no_set_log) 24 | { 25 | Suite *s = suite_create("Suite"); 26 | SRunner *sr = srunner_create(s); 27 | 28 | fail_unless (!srunner_has_log (sr), "SRunner not logging"); 29 | fail_unless (srunner_log_fname(sr) == NULL, "Bad file name returned"); 30 | } 31 | END_TEST 32 | 33 | START_TEST(test_double_set_log) 34 | { 35 | Suite *s = suite_create("Suite"); 36 | SRunner *sr = srunner_create(s); 37 | 38 | srunner_set_log (sr, "test_log"); 39 | srunner_set_log (sr, "test2_log"); 40 | 41 | fail_unless(strcmp(srunner_log_fname(sr), "test_log") == 0, 42 | "Log file is initialize only and shouldn't be changeable once set"); 43 | } 44 | END_TEST 45 | 46 | 47 | START_TEST(test_set_xml) 48 | { 49 | Suite *s = suite_create("Suite"); 50 | SRunner *sr = srunner_create(s); 51 | 52 | srunner_set_xml (sr, "test_log.xml"); 53 | 54 | fail_unless (srunner_has_xml (sr), "SRunner not logging XML"); 55 | fail_unless (strcmp(srunner_xml_fname(sr), "test_log.xml") == 0, 56 | "Bad file name returned"); 57 | } 58 | END_TEST 59 | 60 | START_TEST(test_no_set_xml) 61 | { 62 | Suite *s = suite_create("Suite"); 63 | SRunner *sr = srunner_create(s); 64 | 65 | fail_unless (!srunner_has_xml (sr), "SRunner not logging XML"); 66 | fail_unless (srunner_xml_fname(sr) == NULL, "Bad file name returned"); 67 | } 68 | END_TEST 69 | 70 | START_TEST(test_double_set_xml) 71 | { 72 | Suite *s = suite_create("Suite"); 73 | SRunner *sr = srunner_create(s); 74 | 75 | srunner_set_xml (sr, "test_log.xml"); 76 | srunner_set_xml (sr, "test2_log.xml"); 77 | 78 | fail_unless(strcmp(srunner_xml_fname(sr), "test_log.xml") == 0, 79 | "XML Log file is initialize only and shouldn't be changeable once set"); 80 | } 81 | END_TEST 82 | 83 | Suite *make_log_suite(void) 84 | { 85 | 86 | Suite *s; 87 | TCase *tc_core, *tc_core_xml; 88 | 89 | s = suite_create("Log"); 90 | tc_core = tcase_create("Core"); 91 | tc_core_xml = tcase_create("Core XML"); 92 | 93 | suite_add_tcase(s, tc_core); 94 | tcase_add_test(tc_core, test_set_log); 95 | tcase_add_test(tc_core, test_no_set_log); 96 | tcase_add_test(tc_core, test_double_set_log); 97 | 98 | suite_add_tcase(s, tc_core_xml); 99 | tcase_add_test(tc_core_xml, test_set_xml); 100 | tcase_add_test(tc_core_xml, test_no_set_xml); 101 | tcase_add_test(tc_core_xml, test_double_set_xml); 102 | 103 | return s; 104 | } 105 | 106 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/check_check_log_internal.c: -------------------------------------------------------------------------------- 1 | #include "../lib/libcompat.h" 2 | 3 | /* Tests for log related stuff in check which need non-exported functions. */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "check_check.h" 13 | 14 | 15 | #if ENABLE_SUBUNIT 16 | START_TEST(test_init_logging_subunit) 17 | { 18 | /* init_logging with CK_SUBUNIT sets stdout 19 | * to a subunit function, not any log. 20 | */ 21 | Log * first_log = NULL; 22 | Suite *s = suite_create("Suite"); 23 | SRunner *sr = srunner_create(s); 24 | srunner_init_logging(sr, CK_SUBUNIT); 25 | list_front (sr->loglst); 26 | fail_if (list_at_end(sr->loglst), "No entries in log list"); 27 | first_log = list_val(sr->loglst); 28 | fail_if (first_log == NULL, "log is NULL"); 29 | list_advance(sr->loglst); 30 | fail_unless(list_at_end(sr->loglst), "More than one entry in log list"); 31 | fail_unless(first_log->lfun == subunit_lfun, 32 | "Log function is not the subunit lfun."); 33 | srunner_end_logging(sr); 34 | srunner_free(sr); 35 | } 36 | END_TEST 37 | #endif 38 | 39 | Suite *make_log_internal_suite(void) 40 | { 41 | 42 | Suite *s; 43 | TCase *tc_core_subunit; 44 | 45 | s = suite_create("Log"); 46 | tc_core_subunit = tcase_create("Core SubUnit"); 47 | 48 | #if ENABLE_SUBUNIT 49 | suite_add_tcase(s, tc_core_subunit); 50 | tcase_add_test(tc_core_subunit, test_init_logging_subunit); 51 | #endif 52 | 53 | return s; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/check_check_main.c: -------------------------------------------------------------------------------- 1 | #include "../lib/libcompat.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include "check_check.h" 7 | 8 | int main (void) 9 | { 10 | int n; 11 | SRunner *sr; 12 | 13 | #ifdef _POSIX_VERSION 14 | fork_setup(); 15 | setup_fixture(); 16 | setup(); 17 | #endif /* _POSIX_VERSION */ 18 | 19 | sr = srunner_create (make_master_suite()); 20 | srunner_add_suite(sr, make_list_suite()); 21 | srunner_add_suite(sr, make_msg_suite()); 22 | srunner_add_suite(sr, make_log_suite()); 23 | srunner_add_suite(sr, make_log_internal_suite()); 24 | srunner_add_suite(sr, make_limit_suite()); 25 | srunner_add_suite(sr, make_fork_suite()); 26 | srunner_add_suite(sr, make_fixture_suite()); 27 | srunner_add_suite(sr, make_pack_suite()); 28 | srunner_add_suite(sr, make_exit_suite()); 29 | 30 | printf ("Ran %d tests in subordinate suite\n", sub_ntests); 31 | srunner_run_all (sr, CK_VERBOSE); 32 | cleanup(); 33 | fork_teardown(); 34 | teardown_fixture(); 35 | n = srunner_ntests_failed(sr); 36 | srunner_free(sr); 37 | return (n == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 38 | } 39 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/check_check_msg.c: -------------------------------------------------------------------------------- 1 | #include "../lib/libcompat.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "check.h" 8 | #include "check_msg.h" 9 | #include "check_check.h" 10 | 11 | START_TEST(test_send) 12 | { 13 | TestResult *tr; 14 | setup_messaging(); 15 | send_ctx_info(CK_CTX_SETUP); 16 | send_loc_info("abc123.c", 10); 17 | send_ctx_info(CK_CTX_TEST); 18 | send_loc_info("abc124.c", 22); 19 | send_loc_info("abc125.c", 25); 20 | send_failure_info("Oops"); 21 | tr = receive_test_result(0); 22 | teardown_messaging(); 23 | 24 | fail_unless (tr != NULL, 25 | "No test result received"); 26 | fail_unless (tr_ctx(tr) == CK_CTX_TEST, 27 | "Bad CTX received"); 28 | fail_unless (strcmp(tr_msg(tr), "Oops") == 0, 29 | "Bad failure msg received"); 30 | fail_unless (strcmp(tr_lfile(tr), "abc125.c") == 0, 31 | "Bad loc file received"); 32 | fail_unless (tr_lno(tr) == 25, 33 | "Bad loc line received"); 34 | if (tr != NULL) 35 | free(tr); 36 | } 37 | END_TEST 38 | 39 | START_TEST(test_send_big) 40 | { 41 | TestResult *tr; 42 | int i; 43 | 44 | setup_messaging(); 45 | send_ctx_info(CK_CTX_SETUP); 46 | send_loc_info("abc123.c", 10); 47 | for (i = 0; i < 10000; i++) { 48 | send_ctx_info(CK_CTX_TEST); 49 | send_loc_info("abc124.c", i); 50 | } 51 | 52 | tr = receive_test_result(0); 53 | teardown_messaging(); 54 | 55 | fail_unless (tr != NULL, 56 | "No test result received"); 57 | fail_unless (tr_ctx(tr) == CK_CTX_TEST, 58 | "Bad CTX received"); 59 | fail_unless (strcmp(tr_lfile(tr), "abc124.c") == 0, 60 | "Bad loc file received"); 61 | fail_unless (tr_lno(tr) == i -1, 62 | "Bad loc line received"); 63 | if (tr != NULL) 64 | free(tr); 65 | } 66 | END_TEST 67 | 68 | 69 | START_TEST(test_send_test_error) 70 | { 71 | TestResult *tr; 72 | setup_messaging(); 73 | send_ctx_info(CK_CTX_SETUP); 74 | send_loc_info("abc123.c", 10); 75 | send_ctx_info(CK_CTX_TEST); 76 | send_loc_info("abc124.c", 22); 77 | send_loc_info("abc125.c", 25); 78 | tr = receive_test_result(1); 79 | teardown_messaging(); 80 | 81 | fail_unless (tr != NULL, 82 | "No test result received"); 83 | fail_unless (tr_ctx(tr) == CK_CTX_TEST, 84 | "Bad CTX received"); 85 | fail_unless (strcmp(tr_lfile(tr), "abc125.c") == 0, 86 | "Bad loc file received"); 87 | fail_unless (tr_lno(tr) == 25, 88 | "Bad loc line received"); 89 | if (tr != NULL) 90 | free(tr); 91 | } 92 | END_TEST 93 | 94 | START_TEST(test_send_with_passing_teardown) 95 | { 96 | TestResult *tr; 97 | setup_messaging(); 98 | send_ctx_info(CK_CTX_SETUP); 99 | send_loc_info("abc123.c", 10); 100 | send_ctx_info(CK_CTX_TEST); 101 | send_loc_info("abc124.c", 22); 102 | send_loc_info("abc125.c", 25); 103 | send_ctx_info(CK_CTX_TEARDOWN); 104 | send_loc_info("abc126.c", 54); 105 | tr = receive_test_result(0); 106 | teardown_messaging(); 107 | 108 | fail_unless (tr != NULL, 109 | "No test result received"); 110 | fail_unless (tr_ctx(tr) == CK_CTX_TEST, 111 | "Bad CTX received"); 112 | fail_unless (tr_msg(tr) == NULL, 113 | "Bad failure msg received"); 114 | fail_unless (strcmp(tr_lfile(tr), "abc125.c") == 0, 115 | "Bad loc file received"); 116 | fail_unless (tr_lno(tr) == 25, 117 | "Bad loc line received"); 118 | if (tr != NULL) 119 | free(tr); 120 | } 121 | END_TEST 122 | 123 | START_TEST(test_send_with_error_teardown) 124 | { 125 | TestResult *tr; 126 | setup_messaging(); 127 | send_ctx_info(CK_CTX_SETUP); 128 | send_loc_info("abc123.c", 10); 129 | send_ctx_info(CK_CTX_TEST); 130 | send_loc_info("abc124.c", 22); 131 | send_loc_info("abc125.c", 25); 132 | send_ctx_info(CK_CTX_TEARDOWN); 133 | send_loc_info("abc126.c", 54); 134 | tr = receive_test_result(1); 135 | teardown_messaging(); 136 | 137 | fail_unless (tr != NULL, 138 | "No test result received"); 139 | fail_unless (tr_ctx(tr) == CK_CTX_TEARDOWN, 140 | "Bad CTX received"); 141 | fail_unless (tr_msg(tr) == NULL, 142 | "Bad failure msg received"); 143 | fail_unless (strcmp(tr_lfile(tr), "abc126.c") == 0, 144 | "Bad loc file received"); 145 | fail_unless (tr_lno(tr) == 54, 146 | "Bad loc line received"); 147 | if (tr != NULL) 148 | free(tr); 149 | } 150 | END_TEST 151 | 152 | 153 | Suite *make_msg_suite (void) 154 | { 155 | Suite *s; 156 | TCase *tc; 157 | s = suite_create("Msg"); 158 | tc = tcase_create("Core Tests"); 159 | tcase_add_test(tc, test_send); 160 | tcase_add_test(tc, test_send_big); 161 | tcase_add_test(tc, test_send_test_error); 162 | tcase_add_test(tc, test_send_with_passing_teardown); 163 | tcase_add_test(tc, test_send_with_error_teardown); 164 | suite_add_tcase(s, tc); 165 | return s; 166 | } 167 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/check_list.c: -------------------------------------------------------------------------------- 1 | #include "../lib/libcompat.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "check.h" 7 | #include "check_list.h" 8 | #include "check_check.h" 9 | 10 | START_TEST(test_create) 11 | { 12 | List *lp = NULL; 13 | 14 | fail_unless (list_val(lp) == NULL, 15 | "Current list value should be NULL for NULL list"); 16 | 17 | lp = check_list_create(); 18 | 19 | fail_unless (list_val(lp) == NULL, 20 | "Current list value should be NULL for newly created list"); 21 | 22 | fail_unless (list_at_end(lp), 23 | "Newly created list should be at end"); 24 | list_advance(lp); 25 | fail_unless (list_at_end(lp), 26 | "Advancing a list at end should produce a list at end"); 27 | list_free (lp); 28 | } 29 | END_TEST 30 | 31 | START_TEST(test_free) 32 | { 33 | List *lp = check_list_create(); 34 | list_add_end (lp, "abc"); 35 | list_add_end (lp, "123"); 36 | list_add_end (lp, NULL); 37 | list_free (lp); 38 | } 39 | END_TEST 40 | 41 | START_TEST(test_add_end) 42 | { 43 | List * lp = check_list_create(); 44 | const char * tval = "abc"; 45 | 46 | list_add_end (lp, tval); 47 | 48 | fail_unless (list_val (lp) != NULL, 49 | "List current val should not be null after new insertion"); 50 | fail_unless (!list_at_end (lp), 51 | "List should be at end after new insertion"); 52 | fail_unless (strcmp(tval, (char *) list_val (lp)) == 0, 53 | "List current val should equal newly inserted val"); 54 | list_free (lp); 55 | } 56 | END_TEST 57 | 58 | START_TEST(test_add_front) 59 | { 60 | List * lp = check_list_create(); 61 | const char * tval = "abc"; 62 | 63 | list_add_front (lp, tval); 64 | 65 | fail_unless (list_val (lp) != NULL, 66 | "List current val should not be null after new insertion"); 67 | fail_unless (strcmp(tval, (char *) list_val (lp)) == 0, 68 | "List current val should equal newly inserted val"); 69 | list_free (lp); 70 | } 71 | END_TEST 72 | 73 | START_TEST(test_add_end_and_next) 74 | { 75 | List *lp = check_list_create(); 76 | const char *tval1 = "abc"; 77 | const char *tval2 = "123"; 78 | 79 | list_add_end (lp, tval1); 80 | list_add_end (lp, tval2); 81 | list_front(lp); 82 | fail_unless (strcmp (tval1, list_val (lp)) == 0, 83 | "List head val should equal first inserted val"); 84 | list_advance (lp); 85 | fail_unless (!list_at_end (lp), 86 | "List should not be at end after two adds and one next"); 87 | fail_unless (strcmp (tval2, list_val (lp)) == 0, 88 | "List val should equal second inserted val"); 89 | list_advance(lp); 90 | fail_unless (list_at_end (lp), 91 | "List should be at and after two adds and two nexts"); 92 | list_free (lp); 93 | } 94 | END_TEST 95 | 96 | 97 | START_TEST(test_add_front_and_next) 98 | { 99 | List * lp = check_list_create(); 100 | const char *tval1 = "abc"; 101 | const char *tval2 = "123"; 102 | 103 | list_add_front (lp, tval1); 104 | list_add_front (lp, tval2); 105 | list_front(lp); 106 | fail_unless (strcmp (tval2, list_val (lp)) == 0, 107 | "List head val should equal last inserted val"); 108 | list_advance (lp); 109 | fail_unless (!list_at_end (lp), 110 | "List should not be at end after two adds and one next"); 111 | fail_unless (strcmp (tval1, list_val (lp)) == 0, 112 | "List val should equal first inserted val"); 113 | list_advance(lp); 114 | fail_unless (list_at_end (lp), 115 | "List should be at and after two adds and two nexts"); 116 | list_free (lp); 117 | } 118 | END_TEST 119 | 120 | START_TEST(test_add_a_bunch) 121 | { 122 | List *lp; 123 | int i, j; 124 | for (i = 0; i < 3; i++) { 125 | lp = check_list_create(); 126 | for (j = 0; j < 1000; j++) { 127 | list_add_end (lp, "abc"); 128 | list_add_front (lp, "123"); 129 | } 130 | list_free(lp); 131 | } 132 | } 133 | END_TEST 134 | 135 | 136 | Suite *make_list_suite (void) 137 | { 138 | Suite *s = suite_create("Lists"); 139 | TCase * tc = tcase_create("Core"); 140 | 141 | suite_add_tcase (s, tc); 142 | tcase_add_test (tc, test_create); 143 | tcase_add_test (tc, test_free); 144 | tcase_add_test (tc, test_add_end); 145 | tcase_add_test (tc, test_add_front); 146 | tcase_add_test (tc, test_add_end_and_next); 147 | tcase_add_test (tc, test_add_front_and_next); 148 | tcase_add_test (tc, test_add_a_bunch); 149 | return s; 150 | } 151 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/check_stress.c: -------------------------------------------------------------------------------- 1 | #include "../lib/libcompat.h" 2 | 3 | /* note: this test appears pretty useless, so we aren't including it 4 | in the TESTS variable of Makefile.am */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | Suite *s; 12 | TCase *tc; 13 | SRunner *sr; 14 | 15 | START_TEST(test_pass) 16 | { 17 | fail_unless(1,"Shouldn't see this message"); 18 | } 19 | END_TEST 20 | 21 | START_TEST(test_fail) 22 | { 23 | fail("This test fails"); 24 | } 25 | END_TEST 26 | 27 | 28 | static void run (int num_iters) 29 | { 30 | int i; 31 | s = suite_create ("Stress"); 32 | tc = tcase_create ("Stress"); 33 | sr = srunner_create (s); 34 | suite_add_tcase(s, tc); 35 | 36 | for (i = 0; i < num_iters; i++) { 37 | tcase_add_test (tc, test_pass); 38 | tcase_add_test (tc, test_fail); 39 | } 40 | 41 | srunner_run_all(sr, CK_SILENT); 42 | if (srunner_ntests_failed (sr) != num_iters) { 43 | printf ("Error: expected %d failures, got %d\n", 44 | num_iters, srunner_ntests_failed(sr)); 45 | return; 46 | } 47 | 48 | srunner_free(sr); 49 | } 50 | 51 | 52 | int main(void) 53 | { 54 | int i; 55 | time_t t1; 56 | int iters[] = {1, 100, 1000, 2000, 4000, 8000, 10000, 20000, 40000, -1}; 57 | 58 | for (i = 0; iters[i] != -1; i++) { 59 | t1 = time(NULL); 60 | run(iters[i]); 61 | printf ("%d, %d\n", iters[i], (int) difftime(time(NULL), t1)); 62 | } 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/check_thread_stress.c: -------------------------------------------------------------------------------- 1 | #include "../lib/libcompat.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | Suite *s; 8 | TCase *tc; 9 | SRunner *sr; 10 | 11 | #if defined (HAVE_PTHREAD) || defined (_POSIX_VERSION) 12 | static void * 13 | sendinfo (void *userdata CK_ATTRIBUTE_UNUSED) 14 | { 15 | unsigned int i; 16 | for (i = 0; i < 999; i++) 17 | { 18 | fail_unless (1, "Shouldn't see this message"); 19 | } 20 | return NULL; 21 | } 22 | #endif /* HAVE_PTHREAD || _POSIX_VERSION */ 23 | 24 | #ifdef HAVE_PTHREAD 25 | START_TEST (test_stress_threads) 26 | { 27 | pthread_t a, b; 28 | pthread_create (&a, NULL, sendinfo, (void *) 0xa); 29 | pthread_create (&b, NULL, sendinfo, (void *) 0xb); 30 | 31 | pthread_join (a, NULL); 32 | pthread_join (b, NULL); 33 | } 34 | END_TEST 35 | #endif /* HAVE_PTHREAD */ 36 | 37 | #ifdef _POSIX_VERSION 38 | START_TEST (test_stress_forks) 39 | { 40 | pid_t cpid = fork (); 41 | if (cpid == 0) 42 | { 43 | /* child */ 44 | sendinfo ((void *) 0x1); 45 | exit (EXIT_SUCCESS); 46 | } 47 | else 48 | { 49 | /* parent */ 50 | sendinfo ((void *) 0x2); 51 | } 52 | } 53 | END_TEST 54 | #endif /* _POSIX_VERSION */ 55 | 56 | int 57 | main (void) 58 | { 59 | int nf; 60 | s = suite_create ("ForkThreadStress"); 61 | tc = tcase_create ("ForkThreadStress"); 62 | sr = srunner_create (s); 63 | suite_add_tcase (s, tc); 64 | 65 | #ifdef HAVE_PTHREAD 66 | tcase_add_loop_test (tc, test_stress_threads, 0, 100); 67 | #endif /* HAVE_PTHREAD */ 68 | 69 | #ifdef _POSIX_VERSION 70 | tcase_add_loop_test (tc, test_stress_forks, 0, 100); 71 | #endif /* _POSIX_VERSION */ 72 | 73 | srunner_run_all (sr, CK_VERBOSE); 74 | nf = srunner_ntests_failed (sr); 75 | srunner_free (sr); 76 | 77 | /* hack to give us XFAIL on non-posix platforms */ 78 | #ifndef _POSIX_VERSION 79 | nf++; 80 | #endif /* !_POSIX_VERSION */ 81 | 82 | return nf ? EXIT_FAILURE : EXIT_SUCCESS; 83 | } 84 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/ex_log_output.c: -------------------------------------------------------------------------------- 1 | #include "../lib/libcompat.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | START_TEST(test_pass) 9 | { 10 | fail_unless (1==1, "Shouldn't see this"); 11 | } 12 | END_TEST 13 | 14 | START_TEST(test_fail) 15 | { 16 | fail("Failure"); 17 | } 18 | END_TEST 19 | 20 | START_TEST(test_exit) 21 | { 22 | exit(1); 23 | } 24 | END_TEST 25 | 26 | START_TEST(test_pass2) 27 | { 28 | fail_unless (1==1, "Shouldn't see this"); 29 | } 30 | END_TEST 31 | 32 | static Suite *make_s1_suite (void) 33 | { 34 | Suite *s; 35 | TCase *tc; 36 | 37 | s = suite_create("S1"); 38 | tc = tcase_create ("Core"); 39 | suite_add_tcase(s, tc); 40 | tcase_add_test (tc, test_pass); 41 | tcase_add_test (tc, test_fail); 42 | tcase_add_test (tc, test_exit); 43 | 44 | return s; 45 | } 46 | 47 | static Suite *make_s2_suite (void) 48 | { 49 | Suite *s; 50 | TCase *tc; 51 | 52 | s = suite_create("S2"); 53 | tc = tcase_create ("Core"); 54 | suite_add_tcase(s, tc); 55 | tcase_add_test (tc, test_pass2); 56 | 57 | return s; 58 | } 59 | 60 | static void run_tests (int printmode) 61 | { 62 | SRunner *sr; 63 | 64 | sr = srunner_create(make_s1_suite()); 65 | srunner_add_suite(sr, make_s2_suite()); 66 | srunner_set_log(sr, "test.log"); 67 | srunner_run_all(sr, printmode); 68 | srunner_free(sr); 69 | } 70 | 71 | static void usage(void) 72 | { 73 | printf ("Usage: ex_output (CRSILENT | CRMINIMAL | CRNORMAL | CRVERBOSE)\n"); 74 | } 75 | 76 | int main (int argc, char **argv) 77 | { 78 | 79 | if (argc != 2) { 80 | usage(); 81 | return EXIT_FAILURE; 82 | } 83 | 84 | if (strcmp (argv[1], "CK_SILENT") == 0) 85 | run_tests(CK_SILENT); 86 | else if (strcmp (argv[1], "CK_MINIMAL") == 0) 87 | run_tests(CK_MINIMAL); 88 | else if (strcmp (argv[1], "CK_NORMAL") == 0) 89 | run_tests(CK_NORMAL); 90 | else if (strcmp (argv[1], "CK_VERBOSE") == 0) 91 | run_tests(CK_VERBOSE); 92 | else { 93 | usage(); 94 | return EXIT_FAILURE; 95 | } 96 | 97 | 98 | return EXIT_SUCCESS; 99 | } 100 | 101 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/ex_output.c: -------------------------------------------------------------------------------- 1 | #include "../lib/libcompat.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "config.h" 8 | 9 | START_TEST(test_pass) 10 | { 11 | fail_unless (1==1, "Shouldn't see this"); 12 | } 13 | END_TEST 14 | 15 | START_TEST(test_fail) 16 | { 17 | fail("Failure"); 18 | } 19 | END_TEST 20 | 21 | START_TEST(test_exit) 22 | { 23 | exit(1); 24 | } 25 | END_TEST 26 | 27 | static Suite *make_suite (void) 28 | { 29 | Suite *s; 30 | TCase *tc; 31 | 32 | s = suite_create("Master"); 33 | tc = tcase_create ("Core"); 34 | suite_add_tcase(s, tc); 35 | tcase_add_test (tc, test_pass); 36 | tcase_add_test (tc, test_fail); 37 | tcase_add_test (tc, test_exit); 38 | 39 | return s; 40 | } 41 | 42 | static void run_tests (int printmode) 43 | { 44 | SRunner *sr; 45 | Suite *s; 46 | 47 | s = make_suite(); 48 | sr = srunner_create(s); 49 | srunner_run_all(sr, printmode); 50 | srunner_free(sr); 51 | } 52 | 53 | static void print_usage(void) 54 | { 55 | printf ("Usage: ex_output (CK_SILENT | CK_MINIMAL | CK_NORMAL | CK_VERBOSE"); 56 | #if ENABLE_SUBUNIT 57 | printf (" | CK_SUBUNIT"); 58 | #endif 59 | printf (")\n"); 60 | } 61 | 62 | int main (int argc, char **argv) 63 | { 64 | 65 | if (argc != 2) { 66 | print_usage(); 67 | return EXIT_FAILURE; 68 | } 69 | 70 | if (strcmp (argv[1], "CK_SILENT") == 0) 71 | run_tests(CK_SILENT); 72 | else if (strcmp (argv[1], "CK_MINIMAL") == 0) 73 | run_tests(CK_MINIMAL); 74 | else if (strcmp (argv[1], "CK_NORMAL") == 0) 75 | run_tests(CK_NORMAL); 76 | else if (strcmp (argv[1], "CK_VERBOSE") == 0) 77 | run_tests(CK_VERBOSE); 78 | #if ENABLE_SUBUNIT 79 | else if (strcmp (argv[1], "CK_SUBUNIT") == 0) 80 | run_tests(CK_SUBUNIT); 81 | #endif 82 | else { 83 | print_usage(); 84 | return EXIT_FAILURE; 85 | } 86 | 87 | 88 | return EXIT_SUCCESS; 89 | } 90 | 91 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/ex_xml_output.c: -------------------------------------------------------------------------------- 1 | #include "../lib/libcompat.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | START_TEST(test_pass) 9 | { 10 | fail_unless (1==1, "Shouldn't see this"); 11 | } 12 | END_TEST 13 | 14 | START_TEST(test_fail) 15 | { 16 | fail("Failure"); 17 | } 18 | END_TEST 19 | 20 | START_TEST(test_exit) 21 | { 22 | exit(1); 23 | } 24 | END_TEST 25 | 26 | START_TEST(test_pass2) 27 | { 28 | fail_unless (1==1, "Shouldn't see this"); 29 | } 30 | END_TEST 31 | 32 | START_TEST(test_loop) 33 | { 34 | fail_unless (_i==1, "Iteration %d failed", _i); 35 | } 36 | END_TEST 37 | 38 | static Suite *make_s1_suite (void) 39 | { 40 | Suite *s; 41 | TCase *tc; 42 | 43 | s = suite_create("S1"); 44 | tc = tcase_create ("Core"); 45 | suite_add_tcase(s, tc); 46 | tcase_add_test (tc, test_pass); 47 | tcase_add_test (tc, test_fail); 48 | tcase_add_test (tc, test_exit); 49 | 50 | return s; 51 | } 52 | 53 | static Suite *make_s2_suite (void) 54 | { 55 | Suite *s; 56 | TCase *tc; 57 | 58 | s = suite_create("S2"); 59 | tc = tcase_create ("Core"); 60 | suite_add_tcase(s, tc); 61 | tcase_add_test (tc, test_pass2); 62 | tcase_add_loop_test(tc, test_loop, 0, 3); 63 | 64 | return s; 65 | } 66 | 67 | static void run_tests (int printmode) 68 | { 69 | SRunner *sr; 70 | 71 | sr = srunner_create(make_s1_suite()); 72 | srunner_add_suite(sr, make_s2_suite()); 73 | srunner_set_xml(sr, "test.log.xml"); 74 | srunner_run_all(sr, printmode); 75 | srunner_free(sr); 76 | } 77 | 78 | 79 | int main (int argc CK_ATTRIBUTE_UNUSED, char **argv CK_ATTRIBUTE_UNUSED) 80 | { 81 | run_tests(CK_SILENT); /* not considered in XML output */ 82 | 83 | return EXIT_SUCCESS; 84 | } 85 | 86 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/test_log_output.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "${srcdir}" = "." ]; then 4 | lsrc="" 5 | else 6 | lsrc="${srcdir}/" 7 | fi 8 | 9 | expected="Running suite S1 10 | ${lsrc}ex_log_output.c:10:P:Core:test_pass:0: Passed 11 | ${lsrc}ex_log_output.c:16:F:Core:test_fail:0: Failure 12 | ${lsrc}ex_log_output.c:20:E:Core:test_exit:0: (after this point) Early exit with return value 1 13 | Running suite S2 14 | ${lsrc}ex_log_output.c:28:P:Core:test_pass2:0: Passed 15 | Results for all suites run: 16 | 50%: Checks: 4, Failures: 1, Errors: 1" 17 | 18 | 19 | test_log_output ( ) { 20 | 21 | ./ex_log_output "${1}" > /dev/null 22 | actual=`cat test.log` 23 | if [ x"${expected}" != x"${actual}" ]; then 24 | echo "Problem with ex_log_output ${3}"; 25 | echo "Expected:"; 26 | echo "${expected}"; 27 | echo "Got:"; 28 | echo "${actual}"; 29 | exit 1; 30 | fi 31 | 32 | } 33 | 34 | test_log_output "CK_SILENT"; 35 | test_log_output "CK_MINIMAL"; 36 | test_log_output "CK_NORMAL"; 37 | test_log_output "CK_VERBOSE"; 38 | exit 0 39 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/test_output.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./test_vars 4 | 5 | if [ "${srcdir}" = "." ]; then 6 | lsrc="" 7 | else 8 | lsrc="${srcdir}/" 9 | fi 10 | 11 | t0="x" 12 | t1="xRunning suite(s): Master 13 | 33%: Checks: 3, Failures: 1, Errors: 1" 14 | t2="xRunning suite(s): Master 15 | 33%: Checks: 3, Failures: 1, Errors: 1 16 | ${lsrc}ex_output.c:17:F:Core:test_fail:0: Failure 17 | ${lsrc}ex_output.c:21:E:Core:test_exit:0: (after this point) Early exit with return value 1" 18 | t3="xRunning suite(s): Master 19 | 33%: Checks: 3, Failures: 1, Errors: 1 20 | ${lsrc}ex_output.c:11:P:Core:test_pass:0: Passed 21 | ${lsrc}ex_output.c:17:F:Core:test_fail:0: Failure 22 | ${lsrc}ex_output.c:21:E:Core:test_exit:0: (after this point) Early exit with return value 1" 23 | t4="xtest: Core:test_pass 24 | success: Core:test_pass 25 | test: Core:test_fail 26 | failure: Core:test_fail [ 27 | ${lsrc}ex_output.c:17: Failure 28 | ] 29 | test: Core:test_exit 30 | error: Core:test_exit [ 31 | ${lsrc}ex_output.c:21: (after this point) Early exit with return value 1 32 | ]" 33 | 34 | op0=`./ex_output CK_SILENT` 35 | op1=`./ex_output CK_MINIMAL` 36 | op2=`./ex_output CK_NORMAL` 37 | op3=`./ex_output CK_VERBOSE` 38 | if test 1 -eq $ENABLE_SUBUNIT; then 39 | op4=`./ex_output CK_SUBUNIT` 40 | fi 41 | 42 | 43 | test_output ( ) { 44 | if [ "${1}" != "${2}" ]; then 45 | echo "Problem with ex_output ${3}"; 46 | echo "Expected:"; 47 | echo "${1}"; 48 | echo "Got:"; 49 | echo "${2}"; 50 | exit 1; 51 | fi 52 | 53 | } 54 | 55 | test_output "$t0" x"$op0" "CK_SILENT"; 56 | test_output "$t1" x"$op1" "CK_MINIMAL"; 57 | test_output "$t2" x"$op2" "CK_NORMAL"; 58 | test_output "$t3" x"$op3" "CK_VERBOSE"; 59 | if test 1 -eq $ENABLE_SUBUNIT; then 60 | test_output "$t4" x"$op4" "CK_SUBUNIT"; 61 | fi 62 | exit 0 63 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/test_vars: -------------------------------------------------------------------------------- 1 | # defined to 1 if subunit is enabled 2 | export ENABLE_SUBUNIT=0 3 | # defined to 1 if subunit is enabled 4 | export ENABLE_SUBUNIT=0 5 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/test_vars.in: -------------------------------------------------------------------------------- 1 | # defined to 1 if subunit is enabled 2 | export ENABLE_SUBUNIT=@ENABLE_SUBUNIT@ 3 | # defined to 1 if subunit is enabled 4 | export ENABLE_SUBUNIT=@ENABLE_SUBUNIT@ 5 | -------------------------------------------------------------------------------- /deps/check-0.9.8/tests/test_xml_output.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "${srcdir}" = "." ]; then 4 | lsrc="" 5 | else 6 | lsrc="${srcdir}/" 7 | fi 8 | 9 | expected=" 10 | 11 | 12 | S1 13 | 14 | ex_xml_output.c:10 15 | test_pass 16 | 0 17 | Core 18 | Passed 19 | 20 | 21 | ex_xml_output.c:16 22 | test_fail 23 | 0 24 | Core 25 | Failure 26 | 27 | 28 | ex_xml_output.c:20 29 | test_exit 30 | 0 31 | Core 32 | Early exit with return value 1 33 | 34 | 35 | 36 | S2 37 | 38 | ex_xml_output.c:28 39 | test_pass2 40 | 0 41 | Core 42 | Passed 43 | 44 | 45 | ex_xml_output.c:34 46 | test_loop 47 | 0 48 | Core 49 | Iteration 0 failed 50 | 51 | 52 | ex_xml_output.c:34 53 | test_loop 54 | 1 55 | Core 56 | Passed 57 | 58 | 59 | ex_xml_output.c:34 60 | test_loop 61 | 2 62 | Core 63 | Iteration 2 failed 64 | 65 | 66 | " 67 | 68 | ./ex_xml_output > /dev/null 69 | actual=`cat test.log.xml | grep -v \ | grep -v \ | grep -v \` 70 | if [ x"${expected}" != x"${actual}" ]; then 71 | echo "Problem with ex_xml_output ${3}"; 72 | echo "Expected:"; 73 | echo "${expected}"; 74 | echo "Got:"; 75 | echo "${actual}"; 76 | exit 1; 77 | fi 78 | 79 | exit 0 80 | -------------------------------------------------------------------------------- /deps/inih/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | The "inih" library is distributed under the New BSD license: 3 | 4 | Copyright (c) 2009, Brush Technology 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of Brush Technology nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY BRUSH TECHNOLOGY ''AS IS'' AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL BRUSH TECHNOLOGY BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /deps/inih/README.txt: -------------------------------------------------------------------------------- 1 | 2 | inih is a simple .INI file parser written in C, released under the New BSD 3 | license (see LICENSE.txt). Go to the project home page for more info: 4 | 5 | http://code.google.com/p/inih/ 6 | -------------------------------------------------------------------------------- /deps/inih/ini.c: -------------------------------------------------------------------------------- 1 | /* inih -- simple .INI file parser 2 | 3 | inih is released under the New BSD license (see LICENSE.txt). Go to the project 4 | home page for more info: 5 | 6 | http://code.google.com/p/inih/ 7 | 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "ini.h" 15 | 16 | #define MAX_LINE 200 17 | #define MAX_SECTION 50 18 | #define MAX_NAME 50 19 | 20 | /* Strip whitespace chars off end of given string, in place. Return s. */ 21 | static char* rstrip(char* s) 22 | { 23 | char* p = s + strlen(s); 24 | while (p > s && isspace(*--p)) 25 | *p = '\0'; 26 | return s; 27 | } 28 | 29 | /* Return pointer to first non-whitespace char in given string. */ 30 | static char* lskip(const char* s) 31 | { 32 | while (*s && isspace(*s)) 33 | s++; 34 | return (char*)s; 35 | } 36 | 37 | /* Return pointer to first char c or ';' comment in given string, or pointer to 38 | null at end of string if neither found. ';' must be prefixed by a whitespace 39 | character to register as a comment. */ 40 | static char* find_char_or_comment(const char* s, char c) 41 | { 42 | int was_whitespace = 0; 43 | while (*s && *s != c && !(was_whitespace && *s == ';')) { 44 | was_whitespace = isspace(*s); 45 | s++; 46 | } 47 | return (char*)s; 48 | } 49 | 50 | /* Version of strncpy that ensures dest (size bytes) is null-terminated. */ 51 | static char* strncpy0(char* dest, const char* src, size_t size) 52 | { 53 | strncpy(dest, src, size); 54 | dest[size - 1] = '\0'; 55 | return dest; 56 | } 57 | 58 | /* See documentation in header file. */ 59 | int ini_parse_file(FILE* file, 60 | int (*handler)(void*, const char*, const char*, 61 | const char*), 62 | void* user) 63 | { 64 | /* Uses a fair bit of stack (use heap instead if you need to) */ 65 | char line[MAX_LINE]; 66 | char section[MAX_SECTION] = ""; 67 | char prev_name[MAX_NAME] = ""; 68 | 69 | char* start; 70 | char* end; 71 | char* name; 72 | char* value; 73 | int lineno = 0; 74 | int error = 0; 75 | 76 | /* Scan through file line by line */ 77 | while (fgets(line, sizeof(line), file) != NULL) { 78 | lineno++; 79 | start = lskip(rstrip(line)); 80 | 81 | if (*start == ';' || *start == '#') { 82 | /* Per Python ConfigParser, allow '#' comments at start of line */ 83 | } 84 | #if INI_ALLOW_MULTILINE 85 | else if (*prev_name && *start && start > line) { 86 | /* Non-black line with leading whitespace, treat as continuation 87 | of previous name's value (as per Python ConfigParser). */ 88 | if (!handler(user, section, prev_name, start) && !error) 89 | error = lineno; 90 | } 91 | #endif 92 | else if (*start == '[') { 93 | /* A "[section]" line */ 94 | end = find_char_or_comment(start + 1, ']'); 95 | if (*end == ']') { 96 | *end = '\0'; 97 | strncpy0(section, start + 1, sizeof(section)); 98 | *prev_name = '\0'; 99 | } 100 | else if (!error) { 101 | /* No ']' found on section line */ 102 | error = lineno; 103 | } 104 | } 105 | else if (*start && *start != ';') { 106 | /* Not a comment, must be a name[=:]value pair */ 107 | end = find_char_or_comment(start, '='); 108 | if (*end != '=') { 109 | end = find_char_or_comment(start, ':'); 110 | } 111 | if (*end == '=' || *end == ':') { 112 | *end = '\0'; 113 | name = rstrip(start); 114 | value = lskip(end + 1); 115 | end = find_char_or_comment(value, '\0'); 116 | if (*end == ';') 117 | *end = '\0'; 118 | rstrip(value); 119 | 120 | /* Valid name[=:]value pair found, call handler */ 121 | strncpy0(prev_name, name, sizeof(prev_name)); 122 | if (!handler(user, section, name, value) && !error) 123 | error = lineno; 124 | } 125 | else if (!error) { 126 | /* No '=' or ':' found on name[=:]value line */ 127 | error = lineno; 128 | } 129 | } 130 | } 131 | 132 | return error; 133 | } 134 | 135 | /* See documentation in header file. */ 136 | int ini_parse(const char* filename, 137 | int (*handler)(void*, const char*, const char*, const char*), 138 | void* user) 139 | { 140 | FILE* file; 141 | int error; 142 | 143 | file = fopen(filename, "r"); 144 | if (!file) 145 | return -1; 146 | error = ini_parse_file(file, handler, user); 147 | fclose(file); 148 | return error; 149 | } 150 | -------------------------------------------------------------------------------- /deps/inih/ini.h: -------------------------------------------------------------------------------- 1 | /* inih -- simple .INI file parser 2 | 3 | inih is released under the New BSD license (see LICENSE.txt). Go to the project 4 | home page for more info: 5 | 6 | http://code.google.com/p/inih/ 7 | 8 | */ 9 | 10 | #ifndef __INI_H__ 11 | #define __INI_H__ 12 | 13 | /* Make this header file easier to include in C++ code */ 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include 19 | 20 | /* Parse given INI-style file. May have [section]s, name=value pairs 21 | (whitespace stripped), and comments starting with ';' (semicolon). Section 22 | is "" if name=value pair parsed before any section heading. name:value 23 | pairs are also supported as a concession to Python's ConfigParser. 24 | 25 | For each name=value pair parsed, call handler function with given user 26 | pointer as well as section, name, and value (data only valid for duration 27 | of handler call). Handler should return nonzero on success, zero on error. 28 | 29 | Returns 0 on success, line number of first error on parse error (doesn't 30 | stop on first error), or -1 on file open error. 31 | */ 32 | int ini_parse(const char* filename, 33 | int (*handler)(void* user, const char* section, 34 | const char* name, const char* value), 35 | void* user); 36 | 37 | /* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't 38 | close the file when it's finished -- the caller must do that. */ 39 | int ini_parse_file(FILE* file, 40 | int (*handler)(void* user, const char* section, 41 | const char* name, const char* value), 42 | void* user); 43 | 44 | /* Nonzero to allow multi-line value parsing, in the style of Python's 45 | ConfigParser. If allowed, ini_parse() will call the handler with the same 46 | name for each subsequent line parsed. */ 47 | #ifndef INI_ALLOW_MULTILINE 48 | #define INI_ALLOW_MULTILINE 1 49 | #endif 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* __INI_H__ */ 56 | -------------------------------------------------------------------------------- /deps/libev/CVS/Entries: -------------------------------------------------------------------------------- 1 | /Changes/1.251/Sat Feb 4 19:09:28 2012// 2 | /LICENSE/1.9/Tue Aug 4 07:39:22 2009// 3 | /Makefile.am/1.9/Wed Dec 21 18:16:08 2011// 4 | /README/1.20/Thu Apr 24 08:02:15 2008// 5 | /README.embed/1.29/Sat Nov 24 10:10:26 2007// 6 | /Symbols.ev/1.14/Tue Jan 11 13:45:28 2011// 7 | /Symbols.event/1.3/Fri May 23 16:43:45 2008// 8 | /autogen.sh/1.3/Mon May 30 15:28:54 2011// 9 | /configure.ac/1.34/Sat Feb 4 19:09:29 2012// 10 | /ev++.h/1.58/Tue Nov 29 15:10:05 2011// 11 | /ev.3/1.88/Sat Feb 4 18:55:50 2012// 12 | /ev.c/1.410/Sat Feb 4 17:57:55 2012// 13 | /ev.h/1.164/Sat Feb 4 18:55:50 2012// 14 | /ev.pod/1.396/Sat Feb 4 17:57:55 2012// 15 | /ev_epoll.c/1.66/Sun Dec 18 17:47:23 2011// 16 | /ev_kqueue.c/1.51/Sat Jun 4 05:33:29 2011// 17 | /ev_poll.c/1.39/Sat Jun 4 05:33:29 2011// 18 | /ev_port.c/1.28/Sat Jun 4 05:33:29 2011// 19 | /ev_select.c/1.55/Sat Jun 4 05:33:29 2011// 20 | /ev_vars.h/1.49/Thu Jun 30 12:48:40 2011// 21 | /ev_win32.c/1.14/Wed Feb 16 08:02:50 2011// 22 | /ev_wrap.h/1.35/Thu Jun 30 12:48:40 2011// 23 | /event.c/1.50/Wed Feb 16 08:02:51 2011// 24 | /event.h/1.24/Wed Feb 16 08:02:51 2011// 25 | /event_compat.h/1.8/Wed Feb 16 08:02:51 2011// 26 | /import_libevent/1.29/Tue Apr 15 04:34:07 2008// 27 | /libev.m4/1.15/Sun Feb 20 02:56:23 2011// 28 | /update_ev_c/1.2/Wed Jan 18 12:13:14 2012// 29 | /update_ev_wrap/1.4/Thu Dec 20 07:12:57 2007// 30 | /update_symbols/1.1/Wed Dec 19 01:59:29 2007// 31 | D 32 | -------------------------------------------------------------------------------- /deps/libev/CVS/Repository: -------------------------------------------------------------------------------- 1 | libev 2 | -------------------------------------------------------------------------------- /deps/libev/CVS/Root: -------------------------------------------------------------------------------- 1 | :pserver:anonymous@cvs.schmorp.de/schmorpforge 2 | -------------------------------------------------------------------------------- /deps/libev/LICENSE: -------------------------------------------------------------------------------- 1 | All files in libev are Copyright (C)2007,2008,2009 Marc Alexander Lehmann. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following 12 | disclaimer in the documentation and/or other materials provided 13 | with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | Alternatively, the contents of this package may be used under the terms 28 | of the GNU General Public License ("GPL") version 2 or any later version, 29 | in which case the provisions of the GPL are applicable instead of the 30 | above. If you wish to allow the use of your version of this package only 31 | under the terms of the GPL and not to allow others to use your version of 32 | this file under the BSD license, indicate your decision by deleting the 33 | provisions above and replace them with the notice and other provisions 34 | required by the GPL in this and the other files of this package. If you do 35 | not delete the provisions above, a recipient may use your version of this 36 | file under either the BSD or the GPL. 37 | -------------------------------------------------------------------------------- /deps/libev/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | VERSION_INFO = 4:0:0 4 | 5 | EXTRA_DIST = LICENSE Changes libev.m4 autogen.sh \ 6 | ev_vars.h ev_wrap.h \ 7 | ev_epoll.c ev_select.c ev_poll.c ev_kqueue.c ev_port.c ev_win32.c \ 8 | ev.3 ev.pod Symbols.ev Symbols.event 9 | 10 | man_MANS = ev.3 11 | 12 | include_HEADERS = ev.h ev++.h event.h 13 | 14 | lib_LTLIBRARIES = libev.la 15 | 16 | libev_la_SOURCES = ev.c event.c 17 | libev_la_LDFLAGS = -version-info $(VERSION_INFO) 18 | 19 | ev.3: ev.pod 20 | pod2man -n LIBEV -r "libev-$(VERSION)" -c "libev - high performance full featured event loop" -s3 <$< >$@ 21 | -------------------------------------------------------------------------------- /deps/libev/README: -------------------------------------------------------------------------------- 1 | libev is a high-performance event loop/event model with lots of features. 2 | (see benchmark at http://libev.schmorp.de/bench.html) 3 | 4 | 5 | ABOUT 6 | 7 | Homepage: http://software.schmorp.de/pkg/libev 8 | Mailinglist: libev@lists.schmorp.de 9 | http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev 10 | Library Documentation: http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod 11 | 12 | Libev is modelled (very losely) after libevent and the Event perl 13 | module, but is faster, scales better and is more correct, and also more 14 | featureful. And also smaller. Yay. 15 | 16 | Some of the specialties of libev not commonly found elsewhere are: 17 | 18 | - extensive and detailed, readable documentation (not doxygen garbage). 19 | - fully supports fork, can detect fork in various ways and automatically 20 | re-arms kernel mechanisms that do not support fork. 21 | - highly optimised select, poll, epoll, kqueue and event ports backends. 22 | - filesystem object (path) watching (with optional linux inotify support). 23 | - wallclock-based times (using absolute time, cron-like). 24 | - relative timers/timeouts (handle time jumps). 25 | - fast intra-thread communication between multiple 26 | event loops (with optional fast linux eventfd backend). 27 | - extremely easy to embed. 28 | - very small codebase, no bloated library. 29 | - fully extensible by being able to plug into the event loop, 30 | integrate other event loops, integrate other event loop users. 31 | - very little memory use (small watchers, small event loop data). 32 | - optional C++ interface allowing method and function callbacks 33 | at no extra memory or runtime overhead. 34 | - optional Perl interface with similar characteristics (capable 35 | of running Glib/Gtk2 on libev, interfaces with Net::SNMP and 36 | libadns). 37 | - support for other languages (multiple C++ interfaces, D, Ruby, 38 | Python) available from third-parties. 39 | 40 | Examples of programs that embed libev: the EV perl module, 41 | rxvt-unicode, gvpe (GNU Virtual Private Ethernet), the Deliantra MMORPG 42 | server (http://www.deliantra.net/), Rubinius (a next-generation Ruby 43 | VM), the Ebb web server, the Rev event toolkit. 44 | 45 | 46 | CONTRIBUTORS 47 | 48 | libev was written and designed by Marc Lehmann and Emanuele Giaquinta. 49 | 50 | The following people sent in patches or made other noteworthy 51 | contributions to the design (for minor patches, see the Changes 52 | file. If I forgot to include you, please shout at me, it was an 53 | accident): 54 | 55 | W.C.A. Wijngaards 56 | Christopher Layne 57 | Chris Brody 58 | 59 | -------------------------------------------------------------------------------- /deps/libev/README.embed: -------------------------------------------------------------------------------- 1 | This file is now included in the main libev documentation, see 2 | 3 | http://cvs.schmorp.de/libev/ev.html 4 | -------------------------------------------------------------------------------- /deps/libev/Symbols.ev: -------------------------------------------------------------------------------- 1 | ev_async_send 2 | ev_async_start 3 | ev_async_stop 4 | ev_backend 5 | ev_break 6 | ev_check_start 7 | ev_check_stop 8 | ev_child_start 9 | ev_child_stop 10 | ev_cleanup_start 11 | ev_cleanup_stop 12 | ev_clear_pending 13 | ev_default_loop 14 | ev_default_loop_ptr 15 | ev_depth 16 | ev_embed_start 17 | ev_embed_stop 18 | ev_embed_sweep 19 | ev_embeddable_backends 20 | ev_feed_event 21 | ev_feed_fd_event 22 | ev_feed_signal 23 | ev_feed_signal_event 24 | ev_fork_start 25 | ev_fork_stop 26 | ev_idle_start 27 | ev_idle_stop 28 | ev_invoke 29 | ev_invoke_pending 30 | ev_io_start 31 | ev_io_stop 32 | ev_iteration 33 | ev_loop_destroy 34 | ev_loop_fork 35 | ev_loop_new 36 | ev_now 37 | ev_now_update 38 | ev_once 39 | ev_pending_count 40 | ev_periodic_again 41 | ev_periodic_start 42 | ev_periodic_stop 43 | ev_prepare_start 44 | ev_prepare_stop 45 | ev_recommended_backends 46 | ev_ref 47 | ev_resume 48 | ev_run 49 | ev_set_allocator 50 | ev_set_invoke_pending_cb 51 | ev_set_io_collect_interval 52 | ev_set_loop_release_cb 53 | ev_set_syserr_cb 54 | ev_set_timeout_collect_interval 55 | ev_set_userdata 56 | ev_signal_start 57 | ev_signal_stop 58 | ev_sleep 59 | ev_stat_start 60 | ev_stat_stat 61 | ev_stat_stop 62 | ev_supported_backends 63 | ev_suspend 64 | ev_time 65 | ev_timer_again 66 | ev_timer_remaining 67 | ev_timer_start 68 | ev_timer_stop 69 | ev_unref 70 | ev_userdata 71 | ev_verify 72 | ev_version_major 73 | ev_version_minor 74 | -------------------------------------------------------------------------------- /deps/libev/Symbols.event: -------------------------------------------------------------------------------- 1 | event_active 2 | event_add 3 | event_base_dispatch 4 | event_base_free 5 | event_base_loop 6 | event_base_loopexit 7 | event_base_once 8 | event_base_priority_init 9 | event_base_set 10 | event_del 11 | event_dispatch 12 | event_get_method 13 | event_get_version 14 | event_init 15 | event_loop 16 | event_loopexit 17 | event_once 18 | event_pending 19 | event_priority_init 20 | event_priority_set 21 | event_set 22 | -------------------------------------------------------------------------------- /deps/libev/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | autoreconf --install --symlink --force 4 | -------------------------------------------------------------------------------- /deps/libev/configure.ac: -------------------------------------------------------------------------------- 1 | orig_CFLAGS="$CFLAGS" 2 | 3 | AC_INIT 4 | AC_CONFIG_SRCDIR([ev_epoll.c]) 5 | 6 | AM_INIT_AUTOMAKE(libev,4.11) dnl also update ev.h! 7 | AC_CONFIG_HEADERS([config.h]) 8 | AM_MAINTAINER_MODE 9 | 10 | AC_PROG_CC 11 | 12 | dnl Supply default CFLAGS, if not specified 13 | if test -z "$orig_CFLAGS"; then 14 | if test x$GCC = xyes; then 15 | CFLAGS="-g -O3" 16 | fi 17 | fi 18 | 19 | AC_PROG_INSTALL 20 | AC_PROG_LIBTOOL 21 | 22 | m4_include([libev.m4]) 23 | 24 | AC_CONFIG_FILES([Makefile]) 25 | AC_OUTPUT 26 | -------------------------------------------------------------------------------- /deps/libev/ev_poll.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libev poll fd activity backend 3 | * 4 | * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modifica- 8 | * tion, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- 19 | * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- 21 | * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- 25 | * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | * Alternatively, the contents of this file may be used under the terms of 29 | * the GNU General Public License ("GPL") version 2 or any later version, 30 | * in which case the provisions of the GPL are applicable instead of 31 | * the above. If you wish to allow the use of your version of this file 32 | * only under the terms of the GPL and not to allow others to use your 33 | * version of this file under the BSD license, indicate your decision 34 | * by deleting the provisions above and replace them with the notice 35 | * and other provisions required by the GPL. If you do not delete the 36 | * provisions above, a recipient may use your version of this file under 37 | * either the BSD or the GPL. 38 | */ 39 | 40 | #include 41 | 42 | void inline_size 43 | pollidx_init (int *base, int count) 44 | { 45 | /* consider using memset (.., -1, ...), which is practically guaranteed 46 | * to work on all systems implementing poll */ 47 | while (count--) 48 | *base++ = -1; 49 | } 50 | 51 | static void 52 | poll_modify (EV_P_ int fd, int oev, int nev) 53 | { 54 | int idx; 55 | 56 | if (oev == nev) 57 | return; 58 | 59 | array_needsize (int, pollidxs, pollidxmax, fd + 1, pollidx_init); 60 | 61 | idx = pollidxs [fd]; 62 | 63 | if (idx < 0) /* need to allocate a new pollfd */ 64 | { 65 | pollidxs [fd] = idx = pollcnt++; 66 | array_needsize (struct pollfd, polls, pollmax, pollcnt, EMPTY2); 67 | polls [idx].fd = fd; 68 | } 69 | 70 | assert (polls [idx].fd == fd); 71 | 72 | if (nev) 73 | polls [idx].events = 74 | (nev & EV_READ ? POLLIN : 0) 75 | | (nev & EV_WRITE ? POLLOUT : 0); 76 | else /* remove pollfd */ 77 | { 78 | pollidxs [fd] = -1; 79 | 80 | if (expect_true (idx < --pollcnt)) 81 | { 82 | polls [idx] = polls [pollcnt]; 83 | pollidxs [polls [idx].fd] = idx; 84 | } 85 | } 86 | } 87 | 88 | static void 89 | poll_poll (EV_P_ ev_tstamp timeout) 90 | { 91 | struct pollfd *p; 92 | int res; 93 | 94 | EV_RELEASE_CB; 95 | res = poll (polls, pollcnt, timeout * 1e3); 96 | EV_ACQUIRE_CB; 97 | 98 | if (expect_false (res < 0)) 99 | { 100 | if (errno == EBADF) 101 | fd_ebadf (EV_A); 102 | else if (errno == ENOMEM && !syserr_cb) 103 | fd_enomem (EV_A); 104 | else if (errno != EINTR) 105 | ev_syserr ("(libev) poll"); 106 | } 107 | else 108 | for (p = polls; res; ++p) 109 | { 110 | assert (("libev: poll() returned illegal result, broken BSD kernel?", p < polls + pollcnt)); 111 | 112 | if (expect_false (p->revents)) /* this expect is debatable */ 113 | { 114 | --res; 115 | 116 | if (expect_false (p->revents & POLLNVAL)) 117 | fd_kill (EV_A_ p->fd); 118 | else 119 | fd_event ( 120 | EV_A_ 121 | p->fd, 122 | (p->revents & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) 123 | | (p->revents & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) 124 | ); 125 | } 126 | } 127 | } 128 | 129 | int inline_size 130 | poll_init (EV_P_ int flags) 131 | { 132 | backend_mintime = 1e-3; 133 | backend_modify = poll_modify; 134 | backend_poll = poll_poll; 135 | 136 | pollidxs = 0; pollidxmax = 0; 137 | polls = 0; pollmax = 0; pollcnt = 0; 138 | 139 | return EVBACKEND_POLL; 140 | } 141 | 142 | void inline_size 143 | poll_destroy (EV_P) 144 | { 145 | ev_free (pollidxs); 146 | ev_free (polls); 147 | } 148 | 149 | -------------------------------------------------------------------------------- /deps/libev/import_libevent: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | LE=../libevent-1.4.3-stable 4 | 5 | if ! [ -e evbuffer.c ]; then 6 | echo do not run this programm unless you know what you are doing 7 | exit 1 8 | fi 9 | 10 | # this program combines libev and libevent into a single package 11 | 12 | cvs update -AdP libev 13 | rsync -avP libev/. . --exclude CVS 14 | 15 | rm -f configure.ac 16 | 17 | cp $LE/evdns.h . 18 | 19 | perl -i -pe 's%^/.libevent-include./%#include "event_compat.h"%' event.h 20 | 21 | perl -ne ' 22 | s/\s+char buf\[64\];/\tchar buf[96];/; 23 | if (/#include "event.h"/) { 24 | print "#ifndef EV_STANDALONE\n$_#endif\n"; 25 | next; 26 | } 27 | if (/#include "misc.h"/) { 28 | print "#ifndef EV_STANDALONE\n$_#endif\n"; 29 | next; 30 | } 31 | if (/#include "(unistd.h|sys\/time.h)"/) { 32 | print "#ifndef WIN32\n$_#endif\n"; 33 | next; 34 | } 35 | next if /#include "log.h"/; 36 | 37 | print; 38 | ' <$LE/evdns.c >evdns.c 39 | 40 | cp $LE/autogen.sh . 41 | cp $LE/epoll_sub.c . 42 | cp $LE/evbuffer.c . 43 | cp $LE/buffer.c . 44 | cp $LE/evhttp.h . 45 | cp $LE/evutil.h . 46 | cp $LE/evutil.c . 47 | cp $LE/event-config.h . 48 | cp $LE/event-internal.h . 49 | cp $LE/evrpc.h . 50 | cp $LE/evrpc.c . 51 | cp $LE/evrpc-internal.h . 52 | cp $LE/http.c . 53 | cp $LE/event_tagging.c . 54 | cp $LE/http-internal.h . 55 | cp $LE/strlcpy-internal.h . 56 | cp $LE/log.c . 57 | cp $LE/log.h . 58 | cp $LE/strlcpy.c . 59 | rsync -a $LE/WIN32* $LE/sample $LE/test $LE/compat . --del 60 | #rename 's/libevent/libev/' WIN32-Prj/lib* 61 | cp $LE/aclocal.m4 . 62 | #cp $LE/acconfig.h . 63 | cp $LE/config.h.in . 64 | cp $LE/event_rpcgen.py . 65 | cp $LE/*.3 . 66 | 67 | #perl -i -pe 's/libevent/libev/g' sample/Makefile.am 68 | #perl -i -pe 's/libevent/libev/g' test/Makefile.am 69 | 70 | perl -i -pe 's/#include $/#include "event.h"/' test/*.c 71 | 72 | perl -i -ne ' 73 | next if /"event-internal.h"/; 74 | s/base\d?->sig.ev_signal_added/0/; 75 | s/base\d?->sig.ev_signal_pair\[0\]/-1/; 76 | s/base->sig.evsignal_caught/0/; 77 | next if /^\ttest_signal_(dealloc|pipeloss|switchbase|assert|restore)\(\)/; 78 | next if /^\ttest_simplesignal\(\)/; # non-default-loop 79 | next if /^\ttest_immediatesignal\(\)/; # non-default-loop 80 | next if /test_priorities\(\d\)/; 81 | print; 82 | ' test/regress.c 83 | 84 | perl -ne ' 85 | s/\bmin_heap.h\b//g; 86 | s/\bsignal.c\b//g; 87 | s/\bevport.c\b//g; 88 | s/\bkqueue.c\b//g; 89 | s/\bdevpoll.c\b//g; 90 | s/\brtsig.c\b//g; 91 | s/\bselect.c\b//g; 92 | s/\bpoll.c\b//g; 93 | s/\bepoll.c\b//g; 94 | s/\bepoll_sub.c\b//g; 95 | s/\bevent-internal.h\b//g; 96 | s/\bevsignal.h\b//g; 97 | s/^(man_MANS\s*=)/$1 ev.3 /; 98 | s/^(EXTRA_DIST\s*=)/$1 libev.m4 ev.h ev_vars.h ev_wrap.h event_compat.h ev++.h ev_epoll.c ev_select.c ev_poll.c ev_kqueue.c ev_port.c ev_win32.c ev.3 ev.pod /; 99 | s/^(include_HEADERS\s*=)/$1 ev.h event_compat.h ev++.h /; 100 | s/^(CORE_SRC\s*=)/$1 ev.c /; 101 | s/^(SYS_LIBS\s*=)/$1 -lm /; 102 | #s/libevent/libev/g; 103 | print; 104 | ' <$LE/Makefile.am >Makefile.am 105 | 106 | perl -ne ' 107 | #s/-Wall/-Wall -Wno-comment -Wunused-function -Wno-unused-value/; 108 | s/-Wall//g; 109 | #s/libevent/libev/g; 110 | #VERSION 111 | s/AM_INIT_AUTOMAKE\s*\(.*,(.*)\)/AM_INIT_AUTOMAKE(libevent-$1+libev,3.1)/; 112 | s/AC_LIBOBJ\(select\)/: ;/g; 113 | s/AC_LIBOBJ\(poll\)/: ;/g; 114 | s/AC_LIBOBJ\(kqueue\)/: ;/g; 115 | s/AC_LIBOBJ\(epoll\)/: ;/g; 116 | s/AC_LIBOBJ\(devpoll\)/: ;/g; 117 | s/AC_LIBOBJ\(evport\)/: ;/g; 118 | s/AC_LIBOBJ\(signal\)/: ;/g; 119 | s/AC_LIBOBJ\(rtsig\)/: ;/g; 120 | print "m4_include([libev.m4])\n" if /^AC_OUTPUT/; 121 | print; 122 | ' <$LE/configure.in >configure.in 123 | 124 | aclocal-1.7 125 | automake-1.7 --add-missing 126 | autoconf 127 | autoheader 128 | libtoolize 129 | CC="ccache gcc" ./configure --prefix=/opt/libev --disable-shared "$@" 130 | 131 | 132 | -------------------------------------------------------------------------------- /deps/libev/libev.m4: -------------------------------------------------------------------------------- 1 | dnl this file is part of libev, do not make local modifications 2 | dnl http://software.schmorp.de/pkg/libev 3 | 4 | dnl libev support 5 | AC_CHECK_HEADERS(sys/inotify.h sys/epoll.h sys/event.h port.h poll.h sys/select.h sys/eventfd.h sys/signalfd.h) 6 | 7 | AC_CHECK_FUNCS(inotify_init epoll_ctl kqueue port_create poll select eventfd signalfd) 8 | 9 | AC_CHECK_FUNCS(clock_gettime, [], [ 10 | dnl on linux, try syscall wrapper first 11 | if test $(uname) = Linux; then 12 | AC_MSG_CHECKING(for clock_gettime syscall) 13 | AC_LINK_IFELSE([AC_LANG_PROGRAM( 14 | [#include 15 | #include 16 | #include ], 17 | [struct timespec ts; int status = syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts)])], 18 | [ac_have_clock_syscall=1 19 | AC_DEFINE(HAVE_CLOCK_SYSCALL, 1, Define to 1 to use the syscall interface for clock_gettime) 20 | AC_MSG_RESULT(yes)], 21 | [AC_MSG_RESULT(no)]) 22 | fi 23 | if test -z "$LIBEV_M4_AVOID_LIBRT" && test -z "$ac_have_clock_syscall"; then 24 | AC_CHECK_LIB(rt, clock_gettime) 25 | unset ac_cv_func_clock_gettime 26 | AC_CHECK_FUNCS(clock_gettime) 27 | fi 28 | ]) 29 | 30 | AC_CHECK_FUNCS(nanosleep, [], [ 31 | if test -z "$LIBEV_M4_AVOID_LIBRT"; then 32 | AC_CHECK_LIB(rt, nanosleep) 33 | unset ac_cv_func_nanosleep 34 | AC_CHECK_FUNCS(nanosleep) 35 | fi 36 | ]) 37 | 38 | if test -z "$LIBEV_M4_AVOID_LIBM"; then 39 | LIBM=m 40 | fi 41 | AC_SEARCH_LIBS(floor, $LIBM, [AC_DEFINE(HAVE_FLOOR, 1, Define to 1 if the floor function is available)]) 42 | 43 | -------------------------------------------------------------------------------- /deps/libev/update_ev_c: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | ( 4 | sed -ne '1,\%/\* ECB.H BEGIN \*/%p' ev.c 5 | cat ~/src/libecb/ecb.h 6 | sed -ne '\%/\* ECB.H END \*/%,$p' ev.c 7 | ) >ev.c~ && mv ev.c~ ev.c 8 | 9 | -------------------------------------------------------------------------------- /deps/libev/update_ev_wrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ( 4 | echo '#define VAR(name,decl) name' 5 | echo '#define EV_GENWRAP 1' 6 | cat ev_vars.h 7 | ) | cc -E -o - - | perl -ne ' 8 | while (<>) { 9 | push @syms, $1 if /(^\w+)/; 10 | } 11 | print "/* DO NOT EDIT, automatically generated by update_ev_wrap */\n", 12 | "#ifndef EV_WRAP_H\n", 13 | "#define EV_WRAP_H\n", 14 | (map "#define $_ ((loop)->$_)\n", @syms), 15 | "#else\n", 16 | "#undef EV_WRAP_H\n", 17 | (map "#undef $_\n", @syms), 18 | "#endif\n"; 19 | ' >ev_wrap.h 20 | -------------------------------------------------------------------------------- /deps/libev/update_symbols: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | make ev.o event.o || exit 4 | 5 | nm ev.o | perl -ne 'print "$1\n" if /\S+ [A-Z] (\S+)/' > Symbols.ev 6 | nm event.o | perl -ne 'print "$1\n" if /\S+ [A-Z] (\S+)/' > Symbols.event 7 | 8 | -------------------------------------------------------------------------------- /deps/murmurhash/MurmurHash3.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // MurmurHash3 was written by Austin Appleby, and is placed in the public 3 | // domain. The author hereby disclaims copyright to this source code. 4 | 5 | #ifndef _MURMURHASH3_H_ 6 | #define _MURMURHASH3_H_ 7 | 8 | //----------------------------------------------------------------------------- 9 | // Platform-specific functions and macros 10 | 11 | // Microsoft Visual Studio 12 | 13 | #if defined(_MSC_VER) 14 | 15 | typedef unsigned char uint8_t; 16 | typedef unsigned long uint32_t; 17 | typedef unsigned __int64 uint64_t; 18 | 19 | // Other compilers 20 | 21 | #else // defined(_MSC_VER) 22 | 23 | #include 24 | 25 | #endif // !defined(_MSC_VER) 26 | 27 | //----------------------------------------------------------------------------- 28 | 29 | extern "C" void MurmurHash3_x86_32 ( const void * key, int len, uint32_t seed, void * out ); 30 | 31 | extern "C" void MurmurHash3_x86_128 ( const void * key, int len, uint32_t seed, void * out ); 32 | 33 | extern "C" void MurmurHash3_x64_128 ( const void * key, int len, uint32_t seed, void * out ); 34 | 35 | //----------------------------------------------------------------------------- 36 | 37 | #endif // _MURMURHASH3_H_ 38 | -------------------------------------------------------------------------------- /src/art.h: -------------------------------------------------------------------------------- 1 | #include 2 | #ifndef ART_H 3 | #define ART_H 4 | 5 | #define NODE4 1 6 | #define NODE16 2 7 | #define NODE48 3 8 | #define NODE256 4 9 | 10 | #define MAX_PREFIX_LEN 10 11 | 12 | typedef int(*art_callback)(void *data, const unsigned char *key, uint32_t key_len, void *value); 13 | 14 | /** 15 | * This struct is included as part 16 | * of all the various node sizes 17 | */ 18 | typedef struct { 19 | uint8_t type; 20 | uint8_t num_children; 21 | uint32_t partial_len; 22 | unsigned char partial[MAX_PREFIX_LEN]; 23 | } art_node; 24 | 25 | /** 26 | * Small node with only 4 children 27 | */ 28 | typedef struct { 29 | art_node n; 30 | unsigned char keys[4]; 31 | art_node *children[4]; 32 | } art_node4; 33 | 34 | /** 35 | * Node with 16 children 36 | */ 37 | typedef struct { 38 | art_node n; 39 | unsigned char keys[16]; 40 | art_node *children[16]; 41 | } art_node16; 42 | 43 | /** 44 | * Node with 48 children, but 45 | * a full 256 byte field. 46 | */ 47 | typedef struct { 48 | art_node n; 49 | unsigned char keys[256]; 50 | art_node *children[48]; 51 | } art_node48; 52 | 53 | /** 54 | * Full node with 256 children 55 | */ 56 | typedef struct { 57 | art_node n; 58 | art_node *children[256]; 59 | } art_node256; 60 | 61 | /** 62 | * Represents a leaf. These are 63 | * of arbitrary size, as they include the key. 64 | */ 65 | typedef struct { 66 | uint16_t ref_count; 67 | void *value; 68 | uint32_t key_len; 69 | unsigned char key[]; 70 | } art_leaf; 71 | 72 | /** 73 | * Main struct, points to root. 74 | */ 75 | typedef struct { 76 | art_node *root; 77 | uint64_t size; 78 | } art_tree; 79 | 80 | /** 81 | * Initializes an ART tree 82 | * @return 0 on success. 83 | */ 84 | int init_art_tree(art_tree *t); 85 | 86 | /** 87 | * Destroys an ART tree 88 | * @return 0 on success. 89 | */ 90 | int destroy_art_tree(art_tree *t); 91 | 92 | /** 93 | * Returns the size of the ART tree. 94 | */ 95 | inline uint64_t art_size(art_tree *t) { 96 | return t->size; 97 | } 98 | 99 | /** 100 | * Inserts a new value into the ART tree 101 | * @arg t The tree 102 | * @arg key The key 103 | * @arg key_len The length of the key 104 | * @arg value Opaque value. 105 | * @return NULL if the item was newly inserted, otherwise 106 | * the old value pointer is returned. 107 | */ 108 | void* art_insert(art_tree *t, unsigned char *key, int key_len, void *value); 109 | 110 | /** 111 | * Deletes a value from the ART tree 112 | * @arg t The tree 113 | * @arg key The key 114 | * @arg key_len The length of the key 115 | * @return NULL if the item was not found, otherwise 116 | * the value pointer is returned. 117 | */ 118 | void* art_delete(art_tree *t, unsigned char *key, int key_len); 119 | 120 | /** 121 | * Searches for a value in the ART tree 122 | * @arg t The tree 123 | * @arg key The key 124 | * @arg key_len The length of the key 125 | * @return NULL if the item was not found, otherwise 126 | * the value pointer is returned. 127 | */ 128 | void* art_search(art_tree *t, unsigned char *key, int key_len); 129 | 130 | /** 131 | * Returns the minimum valued leaf 132 | * @return The minimum leaf or NULL 133 | */ 134 | art_leaf* art_minimum(art_tree *t); 135 | 136 | /** 137 | * Returns the maximum valued leaf 138 | * @return The maximum leaf or NULL 139 | */ 140 | art_leaf* art_maximum(art_tree *t); 141 | 142 | /** 143 | * Iterates through the entries pairs in the map, 144 | * invoking a callback for each. The call back gets a 145 | * key, value for each and returns an integer stop value. 146 | * If the callback returns non-zero, then the iteration stops. 147 | * @arg t The tree to iterate over 148 | * @arg cb The callback function to invoke 149 | * @arg data Opaque handle passed to the callback 150 | * @return 0 on success, or the return of the callback. 151 | */ 152 | int art_iter(art_tree *t, art_callback cb, void *data); 153 | 154 | /** 155 | * Iterates through the entries pairs in the map, 156 | * invoking a callback for each that matches a given prefix. 157 | * The call back gets a key, value for each and returns an integer stop value. 158 | * If the callback returns non-zero, then the iteration stops. 159 | * @arg t The tree to iterate over 160 | * @arg prefix The prefix of keys to read 161 | * @arg prefix_len The length of the prefix 162 | * @arg cb The callback function to invoke 163 | * @arg data Opaque handle passed to the callback 164 | * @return 0 on success, or the return of the callback. 165 | */ 166 | int art_iter_prefix(art_tree *t, unsigned char *prefix, int prefix_len, art_callback cb, void *data); 167 | 168 | /** 169 | * Creates a copy of an ART tree. The two trees will 170 | * share the internal leaves, but will NOT share internal nodes. 171 | * This allows leaves to be added and deleted from each tree 172 | * individually. It is important that concurrent updates to 173 | * a given key has no well defined behavior since the leaves are 174 | * shared. 175 | * @arg dst The destination tree. Not initialized yet. 176 | * @arg src The source tree, must be initialized. 177 | * @return 0 on success. 178 | */ 179 | int art_copy(art_tree *dst, art_tree *src); 180 | 181 | #endif 182 | -------------------------------------------------------------------------------- /src/background.h: -------------------------------------------------------------------------------- 1 | #ifndef BACKGROUND_H 2 | #define BACKGROUND_H 3 | #include 4 | #include "config.h" 5 | #include "set_manager.h" 6 | 7 | /** 8 | * Starts a flushing thread which on every 9 | * configured flush interval, flushes all the sets. 10 | * @arg config The configuration 11 | * @arg mgr The manager to use 12 | * @arg should_run Pointer to an integer that is set to 0 to 13 | * indicate the thread should exit. 14 | * @arg t The output thread 15 | * @return 1 if the thread was started 16 | */ 17 | int start_flush_thread(hlld_config *config, hlld_setmgr *mgr, int *should_run, pthread_t *t); 18 | 19 | /** 20 | * Starts a cold unmap thread which on every 21 | * cold interval unamps cold sets. 22 | * @arg config The configuration 23 | * @arg mgr The manager to use 24 | * @arg should_run Pointer to an integer that is set to 0 to 25 | * indicate the thread should exit. 26 | * @arg t The output thread 27 | * @return 1 if the thread was started 28 | */ 29 | int start_cold_unmap_thread(hlld_config *config, hlld_setmgr *mgr, int *should_run, pthread_t *); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/barrier.c: -------------------------------------------------------------------------------- 1 | /* 2 | * barrier.c 3 | * 4 | * This file implements the "barrier" synchronization construct. 5 | * 6 | * A barrier causes threads to wait until a set of threads has 7 | * all "reached" the barrier. The number of threads required is 8 | * set when the barrier is initialized, and cannot be changed 9 | * except by reinitializing. 10 | * 11 | * The barrier_init() and barrier_destroy() functions, 12 | * respectively, allow you to initialize and destroy the 13 | * barrier. 14 | * 15 | * The barrier_wait() function allows a thread to wait for a 16 | * barrier to be completed. One thread (the one that happens to 17 | * arrive last) will return from barrier_wait() with the status 18 | * -1 on success -- others will return with 0. The special 19 | * status makes it easy for the calling code to cause one thread 20 | * to do something in a serial region before entering another 21 | * parallel section of code. 22 | * 23 | * From: http://ptgmedia.pearsoncmg.com/images/0201633922/sourcecode/barrier.c 24 | * 25 | */ 26 | #include 27 | #include 28 | #include "barrier.h" 29 | 30 | /* 31 | * Initialize a barrier for use. 32 | */ 33 | int barrier_init (barrier_t *barrier, int count) 34 | { 35 | int status; 36 | 37 | barrier->threshold = barrier->counter = count; 38 | barrier->cycle = 0; 39 | status = pthread_mutex_init (&barrier->mutex, NULL); 40 | if (status != 0) 41 | return status; 42 | status = pthread_cond_init (&barrier->cv, NULL); 43 | if (status != 0) { 44 | pthread_mutex_destroy (&barrier->mutex); 45 | return status; 46 | } 47 | barrier->valid = BARRIER_VALID; 48 | return 0; 49 | } 50 | 51 | /* 52 | * Destroy a barrier when done using it. 53 | */ 54 | int barrier_destroy (barrier_t *barrier) 55 | { 56 | int status, status2; 57 | 58 | if (barrier->valid != BARRIER_VALID) 59 | return EINVAL; 60 | 61 | status = pthread_mutex_lock (&barrier->mutex); 62 | if (status != 0) 63 | return status; 64 | 65 | /* 66 | * Check whether any threads are known to be waiting; report 67 | * "BUSY" if so. 68 | */ 69 | if (barrier->counter != barrier->threshold) { 70 | pthread_mutex_unlock (&barrier->mutex); 71 | return EBUSY; 72 | } 73 | 74 | barrier->valid = 0; 75 | status = pthread_mutex_unlock (&barrier->mutex); 76 | if (status != 0) 77 | return status; 78 | 79 | /* 80 | * If unable to destroy either 1003.1c synchronization 81 | * object, return the error status. 82 | */ 83 | status = pthread_mutex_destroy (&barrier->mutex); 84 | status2 = pthread_cond_destroy (&barrier->cv); 85 | return (status == 0 ? status : status2); 86 | } 87 | 88 | /* 89 | * Wait for all members of a barrier to reach the barrier. When 90 | * the count (of remaining members) reaches 0, broadcast to wake 91 | * all threads waiting. 92 | */ 93 | int barrier_wait (barrier_t *barrier) 94 | { 95 | int status, cancel, tmp, cycle; 96 | 97 | if (barrier->valid != BARRIER_VALID) 98 | return EINVAL; 99 | 100 | status = pthread_mutex_lock (&barrier->mutex); 101 | if (status != 0) 102 | return status; 103 | 104 | cycle = barrier->cycle; /* Remember which cycle we're on */ 105 | 106 | if (--barrier->counter == 0) { 107 | barrier->cycle = !barrier->cycle; 108 | barrier->counter = barrier->threshold; 109 | status = pthread_cond_broadcast (&barrier->cv); 110 | /* 111 | * The last thread into the barrier will return status 112 | * -1 rather than 0, so that it can be used to perform 113 | * some special serial code following the barrier. 114 | */ 115 | if (status == 0) 116 | status = -1; 117 | } else { 118 | /* 119 | * Wait with cancellation disabled, because barrier_wait 120 | * should not be a cancellation point. 121 | */ 122 | pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &cancel); 123 | 124 | /* 125 | * Wait until the barrier's cycle changes, which means 126 | * that it has been broadcast, and we don't want to wait 127 | * anymore. 128 | */ 129 | while (cycle == barrier->cycle) { 130 | status = pthread_cond_wait ( 131 | &barrier->cv, &barrier->mutex); 132 | if (status != 0) break; 133 | } 134 | 135 | pthread_setcancelstate (cancel, &tmp); 136 | } 137 | /* 138 | * Ignore an error in unlocking. It shouldn't happen, and 139 | * reporting it here would be misleading -- the barrier wait 140 | * completed, after all, whereas returning, for example, 141 | * EINVAL would imply the wait had failed. The next attempt 142 | * to use the barrier *will* return an error, or hang, due 143 | * to whatever happened to the mutex. 144 | */ 145 | pthread_mutex_unlock (&barrier->mutex); 146 | return status; /* error, -1 for waker, or 0 */ 147 | } 148 | -------------------------------------------------------------------------------- /src/barrier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * barrier.h 3 | * 4 | * This header file describes the "barrier" synchronization 5 | * construct. The type barrier_t describes the full state of the 6 | * barrier including the POSIX 1003.1c synchronization objects 7 | * necessary. 8 | * 9 | * A barrier causes threads to wait until a set of threads has 10 | * all "reached" the barrier. The number of threads required is 11 | * set when the barrier is initialized, and cannot be changed 12 | * except by reinitializing. 13 | * 14 | * From: http://ptgmedia.pearsoncmg.com/images/0201633922/sourcecode/barrier.h 15 | */ 16 | #include 17 | 18 | /* 19 | * Structure describing a barrier. 20 | */ 21 | typedef struct barrier_tag { 22 | pthread_mutex_t mutex; /* Control access to barrier */ 23 | pthread_cond_t cv; /* wait for barrier */ 24 | int valid; /* set when valid */ 25 | int threshold; /* number of threads required */ 26 | int counter; /* current number of threads */ 27 | int cycle; /* alternate wait cycles (0 or 1) */ 28 | } barrier_t; 29 | 30 | #define BARRIER_VALID 0xdbcafe 31 | 32 | /* 33 | * Support static initialization of barriers 34 | */ 35 | #define BARRIER_INITIALIZER(cnt) \ 36 | {PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, \ 37 | BARRIER_VALID, cnt, cnt, 0} 38 | 39 | /* 40 | * Define barrier functions 41 | */ 42 | extern int barrier_init (barrier_t *barrier, int count); 43 | extern int barrier_destroy (barrier_t *barrier); 44 | extern int barrier_wait (barrier_t *barrier); 45 | 46 | -------------------------------------------------------------------------------- /src/bitmap.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAP_H 2 | #define BITMAP_H 3 | #include 4 | #include 5 | #include 6 | 7 | typedef enum { 8 | SHARED = 1, // MAP_SHARED mmap used, file backed. 9 | PERSISTENT = 2, // MAP_ANONYMOUS used, file backed. 10 | ANONYMOUS = 4, // MAP_ANONYMOUS mmap used. No file backing. 11 | NEW_BITMAP = 8 // File contents not read. Used with PERSISTENT 12 | } bitmap_mode; 13 | 14 | typedef struct { 15 | bitmap_mode mode; 16 | int fileno; // Underlying fileno 17 | uint64_t size; // Size of bitmap in bytes 18 | unsigned char* mmap; // Starting address of the bitmap region 19 | } hlld_bitmap; 20 | 21 | /** 22 | * Returns a hlld_bitmap pointer from a file handle 23 | * that is already opened with read/write privileges. 24 | * @arg fileno The fileno 25 | * @arg len The length of the bitmap in bytes. 26 | * @arg mode The mode to use for the bitmap. 27 | * @arg map The output map. Will be initialized. 28 | * @return 0 on success. Negative on error. 29 | */ 30 | int bitmap_from_file(int fileno, uint64_t len, bitmap_mode mode, hlld_bitmap *map); 31 | 32 | /** 33 | * Returns a hlld_bitmap pointer from a filename. 34 | * Opens the file with read/write privileges. If create 35 | * is true, then a file will be created if it does not exist. 36 | * If the file cannot be opened, NULL will be returned. 37 | * @arg fileno The fileno 38 | * @arg len The length of the bitmap in bytes. 39 | * @arg create If 1, then the file will be created if it does not exist. 40 | * @arg mode The mode to use for the bitmap. 41 | * @arg map The output map. Will be initialized. 42 | * @return 0 on success. Negative on error. 43 | */ 44 | int bitmap_from_filename(char* filename, uint64_t len, int create, bitmap_mode mode, hlld_bitmap *map); 45 | 46 | /** 47 | * Flushes the bitmap back to disk. This is 48 | * a syncronous operation. It is a no-op for 49 | * ANONYMOUS bitmaps. 50 | * @arg map The bitmap 51 | * @returns 0 on success, negative failure. 52 | */ 53 | int bitmap_flush(hlld_bitmap *map); 54 | 55 | /** 56 | * * Closes and flushes the bitmap. This is 57 | * a syncronous operation. It is a no-op for 58 | * ANONYMOUS bitmaps. The caller should free() 59 | * the structure after. 60 | * @arg map The bitmap 61 | * @returns 0 on success, negative on failure. 62 | */ 63 | int bitmap_close(hlld_bitmap *map); 64 | 65 | /** 66 | * Returns the value of the bit at index idx for the 67 | * hlld_bitmap map 68 | */ 69 | inline int bitmap_getbit(hlld_bitmap *map, uint64_t idx) { 70 | return (map->mmap[idx >> 3] >> (7 - (idx % 8))) & 0x1; 71 | } 72 | 73 | /* 74 | * Used to set a bit in the bitmap, and as a side affect, 75 | * mark the page as dirty if we are in the PERSISTENT mode 76 | */ 77 | inline void bitmap_setbit(hlld_bitmap *map, uint64_t idx) { 78 | unsigned char byte = map->mmap[idx >> 3]; 79 | unsigned char byte_off = 7 - idx % 8; 80 | byte |= 1 << byte_off; 81 | map->mmap[idx >> 3] = byte; 82 | } 83 | 84 | #endif 85 | 86 | 87 | -------------------------------------------------------------------------------- /src/config.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_H 2 | #define CONFIG_H 3 | #include 4 | #include 5 | 6 | /** 7 | * Stores our configuration 8 | */ 9 | typedef struct { 10 | int tcp_port; 11 | int udp_port; 12 | char *bind_address; 13 | char *data_dir; 14 | char *log_level; 15 | int syslog_log_level; 16 | double default_eps; 17 | int default_precision; 18 | int flush_interval; 19 | int cold_interval; 20 | int in_memory; 21 | int worker_threads; 22 | int use_mmap; 23 | } hlld_config; 24 | 25 | /** 26 | * This structure is used to persist 27 | * set specific settings to an INI file. 28 | */ 29 | typedef struct { 30 | double default_eps; 31 | int default_precision; 32 | int in_memory; 33 | uint64_t size; 34 | } hlld_set_config; 35 | 36 | 37 | /** 38 | * Initializes the configuration from a filename. 39 | * Reads the file as an INI configuration, and sets up the 40 | * config object. 41 | * @arg filename The name of the file to read. NULL for defaults. 42 | * @arg config Output. The config object to initialize. 43 | * @return 0 on success, negative on error. 44 | */ 45 | int config_from_filename(char *filename, hlld_config *config); 46 | 47 | /** 48 | * Updates the configuration from a filename. 49 | * Reads the file as an INI configuration and updates the config. 50 | * @arg filename The name of the file to read. 51 | * @arg config Output. The config object to update. Does not initialize! 52 | * @return 0 on success, negative on error. 53 | */ 54 | int set_config_from_filename(char *filename, hlld_set_config *config); 55 | 56 | /** 57 | * Writes the configuration to a filename. 58 | * Writes the file as an INI configuration 59 | * @arg filename The name of the file to write. 60 | * @arg config The config object to write out. 61 | * @return 0 on success, negative on error. 62 | */ 63 | int update_filename_from_set_config(char *filename, hlld_set_config *config); 64 | 65 | /** 66 | * Validates the configuration 67 | * @arg config The config object to validate. 68 | * @return 0 on success, negative on error. 69 | */ 70 | int validate_config(hlld_config *config); 71 | 72 | // Configuration validation methods 73 | int sane_data_dir(char *data_dir); 74 | int sane_log_level(char *log_level, int *syslog_level); 75 | int sane_default_eps(double prob); 76 | int sane_default_precision(int precision); 77 | int sane_flush_interval(int intv); 78 | int sane_cold_interval(int intv); 79 | int sane_in_memory(int in_mem); 80 | int sane_use_mmap(int use_mmap); 81 | int sane_worker_threads(int threads); 82 | 83 | /** 84 | * Joins two strings as part of a path, 85 | * and adds a separating slash if needed. 86 | * @param path Part one of the path 87 | * @param part2 The second part of the path 88 | * @return A new string, that uses a malloc()'d buffer. 89 | */ 90 | char* join_path(char *path, char *part2); 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /src/conn_handler.h: -------------------------------------------------------------------------------- 1 | #ifndef CONN_HANDLER_H 2 | #define CONN_HANDLER_H 3 | #include "config.h" 4 | #include "networking.h" 5 | #include "set_manager.h" 6 | 7 | /** 8 | * This structure is used to communicate 9 | * between the connection handlers and the 10 | * networking layer. 11 | */ 12 | typedef struct { 13 | hlld_config *config; // Global configuration 14 | hlld_setmgr *mgr; // Set manager 15 | hlld_conn_info *conn; // Opaque handle into the networking stack 16 | } hlld_conn_handler; 17 | 18 | /** 19 | * Invoked to initialize the conn handler layer. 20 | */ 21 | void init_conn_handler(); 22 | 23 | /** 24 | * Invoked by the networking layer when there is new 25 | * data to be handled. The connection handler should 26 | * consume all the input possible, and generate responses 27 | * to all requests. 28 | * @arg handle The connection related information 29 | * @return 0 on success. 30 | */ 31 | int handle_client_connect(hlld_conn_handler *handle); 32 | 33 | /** 34 | * Invoked by the networking layer periodically to 35 | * handle state updates. Does not provide 36 | * a connection object as part of the handle. 37 | * @arg handle The connection related information 38 | * @return 0 on success. 39 | */ 40 | void periodic_update(hlld_conn_handler *handle); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/handler_constants.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* 4 | * Various messages and responses 5 | */ 6 | static const char CLIENT_ERR[] = "Client Error: "; 7 | static const int CLIENT_ERR_LEN = sizeof(CLIENT_ERR) - 1; 8 | 9 | static const char CMD_NOT_SUP[] = "Command not supported"; 10 | static const int CMD_NOT_SUP_LEN = sizeof(CMD_NOT_SUP) - 1; 11 | 12 | static const char BAD_ARGS[] = "Bad arguments"; 13 | static const int BAD_ARGS_LEN= sizeof(BAD_ARGS) - 1; 14 | 15 | static const char UNEXPECTED_ARGS[] = "Unexpected arguments"; 16 | static const int UNEXPECTED_ARGS_LEN = sizeof(UNEXPECTED_ARGS) - 1; 17 | 18 | static const char SET_KEY_NEEDED[] = "Must provide set name and key"; 19 | static const int SET_KEY_NEEDED_LEN = sizeof(SET_KEY_NEEDED) - 1; 20 | 21 | static const char SET_NEEDED[] = "Must provide set name"; 22 | static const int SET_NEEDED_LEN = sizeof(SET_NEEDED) - 1; 23 | 24 | static const char BAD_SET_NAME[] = "Bad set name"; 25 | static const int BAD_SET_NAME_LEN = sizeof(BAD_SET_NAME) - 1; 26 | 27 | static const char INTERNAL_ERR[] = "Internal Error\n"; 28 | static const int INTERNAL_ERR_LEN = sizeof(INTERNAL_ERR) - 1; 29 | 30 | static const char SET_NOT_EXIST[] = "Set does not exist\n"; 31 | static const int SET_NOT_EXIST_LEN = sizeof(SET_NOT_EXIST) - 1; 32 | 33 | static const char SET_NOT_PROXIED[] = "Set is not proxied. Close it first.\n"; 34 | static const int SET_NOT_PROXIED_LEN = sizeof(SET_NOT_PROXIED) - 1; 35 | 36 | static const char DELETE_IN_PROGRESS[] = "Delete in progress\n"; 37 | static const int DELETE_IN_PROGRESS_LEN = sizeof(DELETE_IN_PROGRESS) - 1; 38 | 39 | static const char DONE_RESP[] = "Done\n"; 40 | static const int DONE_RESP_LEN = sizeof(DONE_RESP) - 1; 41 | 42 | static const char EXISTS_RESP[] = "Exists\n"; 43 | static const int EXISTS_RESP_LEN = sizeof(EXISTS_RESP) - 1; 44 | 45 | static const char NEW_LINE[] = "\n"; 46 | static const int NEW_LINE_LEN = sizeof(NEW_LINE) - 1; 47 | 48 | static const char START_RESP[] = "START\n"; 49 | static const int START_RESP_LEN = sizeof(START_RESP) - 1; 50 | 51 | static const char END_RESP[] = "END\n"; 52 | static const int END_RESP_LEN = sizeof(END_RESP) - 1; 53 | 54 | typedef enum { 55 | UNKNOWN = 0, // Unrecognized command 56 | SET, // Set a single key 57 | SET_MULTI, // Set multiple space-seperated keys 58 | LIST, // List sets 59 | INFO, // Info about a set 60 | CREATE, // Creates a set 61 | DROP, // Drop a set 62 | CLOSE, // Close a set 63 | CLEAR, // Clears a set from the internals 64 | FLUSH, // Force flush a set 65 | } conn_cmd_type; 66 | 67 | /* Static regexes */ 68 | static regex_t VALID_SET_NAMES_RE; 69 | static const char *VALID_SET_NAMES_PATTERN = "^[^ \t\n\r]{1,200}$"; 70 | 71 | -------------------------------------------------------------------------------- /src/hll.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "bitmap.h" 3 | 4 | #ifndef HLL_H 5 | #define HLL_H 6 | 7 | // Ensure precision in a sane bound 8 | #define HLL_MIN_PRECISION 4 // 16 registers 9 | #define HLL_MAX_PRECISION 18 // 262,144 registers 10 | 11 | typedef struct { 12 | unsigned char precision; 13 | uint32_t *registers; 14 | hlld_bitmap *bm; 15 | } hll_t; 16 | 17 | /** 18 | * Initializes a new HLL 19 | * @arg precision The digits of precision to use 20 | * @arg h The HLL to initialize 21 | * @return 0 on success 22 | */ 23 | int hll_init(unsigned char precision, hll_t *h); 24 | 25 | /** 26 | * Initializes a new HLL from a bitmap 27 | * @arg precision The digits of precision to use 28 | * @arg bm The bitmap to use 29 | * @arg h The HLL to initialize 30 | * @return 0 on success 31 | */ 32 | int hll_init_from_bitmap(unsigned char precision, hlld_bitmap *bm, hll_t *h); 33 | 34 | /** 35 | * Destroys an hll. Closes the bitmap, but does not free it. 36 | * @return 0 on success 37 | */ 38 | int hll_destroy(hll_t *h); 39 | 40 | /** 41 | * Adds a new key to the HLL 42 | * @arg h The hll to add to 43 | * @arg key The key to add 44 | */ 45 | void hll_add(hll_t *h, char *key); 46 | 47 | /** 48 | * Adds a new hash to the HLL 49 | * @arg h The hll to add to 50 | * @arg hash The hash to add 51 | */ 52 | void hll_add_hash(hll_t *h, uint64_t hash); 53 | 54 | /** 55 | * Estimates the cardinality of the HLL 56 | * @arg h The hll to query 57 | * @return An estimate of the cardinality 58 | */ 59 | double hll_size(hll_t *h); 60 | 61 | /** 62 | * Computes the minimum digits of precision 63 | * needed to hit a target error. 64 | * @arg error The target error rate 65 | * @return The number of digits needed, or 66 | * negative on error. 67 | */ 68 | int hll_precision_for_error(double err); 69 | 70 | /** 71 | * Computes the upper bound on variance given 72 | * a precision 73 | * @arg prec The precision to use 74 | * @return The expected variance in the count, 75 | * or zero on error. 76 | */ 77 | double hll_error_for_precision(int prec); 78 | 79 | /** 80 | * Computes the bytes required for a HLL of the 81 | * given precision. 82 | * @arg prec The precision to use 83 | * @return The bytes required or 0 on error. 84 | */ 85 | uint64_t hll_bytes_for_precision(int prec); 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /src/hll_constants.h: -------------------------------------------------------------------------------- 1 | #ifndef HLL_CONSTANT_H 2 | #define HLL_CONSTANT_H 3 | 4 | extern double switchThreshold[15]; 5 | extern double *rawEstimateData[]; 6 | extern double *biasData[]; 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/networking.h: -------------------------------------------------------------------------------- 1 | #ifndef NETWORKING_H 2 | #define NETWORKING_H 3 | #include 4 | #include "config.h" 5 | 6 | // Network configuration struct 7 | typedef struct hlld_networking hlld_networking; 8 | typedef struct conn_info hlld_conn_info; 9 | 10 | /** 11 | * Initializes the networking interfaces 12 | * @arg config Takes the server configuration 13 | * @arg mgr The manager to pass up to the connection handlers 14 | * @arg netconf Output. The configuration for the networking stack. 15 | */ 16 | int init_networking(hlld_config *config, void *mgr, hlld_networking **netconf_out); 17 | 18 | /** 19 | * Entry point for the main thread to start accepting 20 | * @arg netconf The configuration for the networking stack. 21 | * @arg should_run A flag checked to see if we should run 22 | * @arg threads The list of worker threads 23 | */ 24 | void enter_main_loop(hlld_networking *netconf, int *should_run, pthread_t *threads); 25 | 26 | /** 27 | * Entry point for threads to join the networking 28 | * stack. This method blocks indefinitely until the 29 | * network stack is shutdown. 30 | * @arg netconf The configuration for the networking stack. 31 | */ 32 | void start_networking_worker(hlld_networking *netconf); 33 | 34 | /** 35 | * Shuts down all the connections 36 | * and listeners and prepares to exit. 37 | * @arg netconf The config for the networking stack. 38 | * @arg threads A list of worker threads 39 | */ 40 | int shutdown_networking(hlld_networking *netconf, pthread_t *threads); 41 | 42 | /* 43 | * Connection related methods. These are exposed so 44 | * that the connection handlers can manipulate the buffers. 45 | */ 46 | 47 | /** 48 | * Sends a response to a client. 49 | * @arg conn The client connection 50 | * @arg response_buffers A list of response buffers to send 51 | * @arg buf_sizes A list of the buffer sizes 52 | * @arg num_bufs The number of response buffers 53 | * @return 0 on success. 54 | */ 55 | int send_client_response(hlld_conn_info *conn, char **response_buffers, int *buf_sizes, int num_bufs); 56 | 57 | /** 58 | * This method is used to conveniently extract commands from the 59 | * command buffer. It scans up to a terminator, and then sets the 60 | * buf to the start of the buffer, and buf_len to the length 61 | * of the buffer. The output param should_free indicates that 62 | * the caller should free the buffer pointed to by buf when it is finished. 63 | * This method consumes the bytes from the underlying buffer, freeing 64 | * space for later reads. 65 | * @arg conn The client connection 66 | * @arg terminator The terminator charactor to look for. Included in buf. 67 | * @arg buf Output parameter, sets the start of the buffer. 68 | * @arg buf_len Output parameter, the length of the buffer. 69 | * @arg should_free Output parameter, should the buffer be freed by the caller. 70 | * @return 0 on success, -1 if the terminator is not found. 71 | */ 72 | int extract_to_terminator(hlld_conn_info *conn, char terminator, char **buf, int *buf_len, int *should_free); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /src/set.h: -------------------------------------------------------------------------------- 1 | #ifndef SET_H 2 | #define SET_H 3 | #include 4 | #include "config.h" 5 | #include "spinlock.h" 6 | #include "hll.h" 7 | 8 | /* 9 | * Functions are NOT thread safe unless explicitly documented 10 | */ 11 | 12 | /** 13 | * These are the counters that are maintained for each set. 14 | */ 15 | typedef struct { 16 | uint64_t sets; 17 | uint64_t page_ins; 18 | uint64_t page_outs; 19 | } set_counters; 20 | 21 | /** 22 | * Representation of a hyperloglog set 23 | */ 24 | typedef struct hlld_set { 25 | hlld_config *config; // hlld configuration 26 | hlld_set_config set_config; // Set-specific config 27 | 28 | char *set_name; // The name of the set 29 | char *full_path; // Path to our data 30 | 31 | char is_proxied; // Is the bitmap available 32 | pthread_mutex_t hll_lock; // Protects faulting in the HLL 33 | 34 | char is_dirty; // Has a write happened 35 | hlld_bitmap bm; // Bitmap for the HLL 36 | hll_t hll; // Underlying HLL 37 | hlld_spinlock hll_update; // Protect the updates 38 | 39 | set_counters counters; // Counters 40 | } hlld_set; 41 | 42 | /** 43 | * Initializes a set wrapper. 44 | * @arg config The configuration to use 45 | * @arg set_name The name of the set 46 | * @arg discover Should existing data files be discovered. Otherwise 47 | * they will be faulted in on-demand. 48 | * @arg set Output parameter, the new set 49 | * @return 0 on success 50 | */ 51 | int init_set(hlld_config *config, char *set_name, int discover, hlld_set **set); 52 | 53 | /** 54 | * Destroys a set 55 | * @arg set The set to destroy 56 | * @return 0 on success 57 | */ 58 | int destroy_set(hlld_set *set); 59 | 60 | /** 61 | * Gets the counters that belong to a set 62 | * @notes Thread safe, but may be inconsistent. 63 | * @arg set The set 64 | * @return A reference to the counters of a set 65 | */ 66 | set_counters* hset_counters(hlld_set *set); 67 | 68 | /** 69 | * Checks if a set is currectly mapped into 70 | * memory or if it is proxied. 71 | * @notes Thread safe. 72 | * @return 0 if in-memory, 1 if proxied. 73 | */ 74 | int hset_is_proxied(hlld_set *set); 75 | 76 | /** 77 | * Flushes the set. Idempotent if the 78 | * set is proxied or not dirty. 79 | * @arg set The set to close 80 | * @return 0 on success. 81 | */ 82 | int hset_flush(hlld_set *set); 83 | 84 | /** 85 | * Gracefully closes a set. 86 | * @arg set The set to close 87 | * @return 0 on success. 88 | */ 89 | int hset_close(hlld_set *set); 90 | 91 | /** 92 | * Deletes the set with extreme prejudice. 93 | * @arg set The set to delete 94 | * @return 0 on success. 95 | */ 96 | int hset_delete(hlld_set *set); 97 | 98 | /** 99 | * Adds a key to the given set 100 | * @arg set The set to add to 101 | * @arg key The key to add 102 | * @return 0 on success. 103 | */ 104 | int hset_add(hlld_set *set, char *key); 105 | 106 | /** 107 | * Gets the size of the set 108 | * @note Thread safe. 109 | * @arg set The set to check 110 | * @return The estimated size of the set 111 | */ 112 | uint64_t hset_size(hlld_set *set); 113 | 114 | /** 115 | * Gets the byte size of the set 116 | * @note Thread safe. 117 | * @arg set The set 118 | * @return The total byte size of the set 119 | */ 120 | uint64_t hset_byte_size(hlld_set *set); 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /src/spinlock.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #ifndef SPINLOCK_H 5 | #define SPINLOCK_H 6 | 7 | #ifdef __MACH__ 8 | // On OSX use OSAtomic 9 | #include 10 | typedef OSSpinLock hlld_spinlock; 11 | #define INIT_HLLD_SPIN(spin) { *spin = OS_SPINLOCK_INIT; } 12 | #define LOCK_HLLD_SPIN(spin) { OSSpinLockLock(spin); } 13 | #define UNLOCK_HLLD_SPIN(spin) { OSSpinLockUnlock(spin); } 14 | 15 | #else 16 | #ifdef _POSIX_SPIN_LOCKS 17 | // On most POSIX systems, use pthreads spin locks 18 | typedef pthread_spinlock_t hlld_spinlock; 19 | #define INIT_HLLD_SPIN(spin) { pthread_spin_init(spin, PTHREAD_PROCESS_PRIVATE); } 20 | #define LOCK_HLLD_SPIN(spin) { pthread_spin_lock(spin); } 21 | #define UNLOCK_HLLD_SPIN(spin) { pthread_spin_unlock(spin); } 22 | 23 | #else 24 | // Fall back onto a mutex 25 | typedef pthread_mutex_t hlld_spinlock; 26 | #define INIT_HLLD_SPIN(spin) { pthread_mutex_init(spin, NULL); } 27 | #define LOCK_HLLD_SPIN(spin) { pthread_mutex_lock(spin); } 28 | #define UNLOCK_HLLD_SPIN(spin) { pthread_mutex_unlock(spin); } 29 | 30 | #endif 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/type_compat.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef __MACH__ 4 | #define __MAC_10_8 1080 5 | #include 6 | #if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8 7 | #define CONST_DIRENT_T struct dirent 8 | #else 9 | #define CONST_DIRENT_T const struct dirent 10 | #endif 11 | #else 12 | #define CONST_DIRENT_T const struct dirent 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /tests/test_hll.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "hll.h" 10 | 11 | START_TEST(test_hll_init_bad) 12 | { 13 | hll_t h; 14 | fail_unless(hll_init(HLL_MIN_PRECISION-1, &h) == -1); 15 | fail_unless(hll_init(HLL_MAX_PRECISION+1, &h) == -1); 16 | 17 | fail_unless(hll_init(HLL_MIN_PRECISION, &h) == 0); 18 | fail_unless(hll_destroy(&h) == 0); 19 | 20 | fail_unless(hll_init(HLL_MAX_PRECISION, &h) == 0); 21 | fail_unless(hll_destroy(&h) == 0); 22 | } 23 | END_TEST 24 | 25 | 26 | START_TEST(test_hll_init_and_destroy) 27 | { 28 | hll_t h; 29 | fail_unless(hll_init(10, &h) == 0); 30 | fail_unless(hll_destroy(&h) == 0); 31 | } 32 | END_TEST 33 | 34 | START_TEST(test_hll_add) 35 | { 36 | hll_t h; 37 | fail_unless(hll_init(10, &h) == 0); 38 | 39 | char buf[100]; 40 | for (int i=0; i < 100; i++) { 41 | fail_unless(sprintf((char*)&buf, "test%d", i)); 42 | hll_add(&h, (char*)&buf); 43 | } 44 | 45 | fail_unless(hll_destroy(&h) == 0); 46 | } 47 | END_TEST 48 | 49 | START_TEST(test_hll_add_hash) 50 | { 51 | hll_t h; 52 | fail_unless(hll_init(10, &h) == 0); 53 | 54 | for (uint64_t i=0; i < 100; i++) { 55 | hll_add_hash(&h, i ^ rand()); 56 | } 57 | 58 | fail_unless(hll_destroy(&h) == 0); 59 | } 60 | END_TEST 61 | 62 | START_TEST(test_hll_add_size) 63 | { 64 | hll_t h; 65 | fail_unless(hll_init(10, &h) == 0); 66 | 67 | char buf[100]; 68 | for (int i=0; i < 100; i++) { 69 | fail_unless(sprintf((char*)&buf, "test%d", i)); 70 | hll_add(&h, (char*)&buf); 71 | } 72 | 73 | double s = hll_size(&h); 74 | fail_unless(s > 95 && s < 105); 75 | 76 | fail_unless(hll_destroy(&h) == 0); 77 | } 78 | END_TEST 79 | 80 | START_TEST(test_hll_add_size_bitmap) 81 | { 82 | hlld_bitmap bm; 83 | uint64_t bytes = hll_bytes_for_precision(10); 84 | fail_unless(bitmap_from_file(-1, bytes, ANONYMOUS, &bm) == 0); 85 | 86 | hll_t h; 87 | fail_unless(hll_init_from_bitmap(10, &bm, &h) == 0); 88 | 89 | char buf[100]; 90 | for (int i=0; i < 100; i++) { 91 | fail_unless(sprintf((char*)&buf, "test%d", i)); 92 | hll_add(&h, (char*)&buf); 93 | } 94 | 95 | double s = hll_size(&h); 96 | fail_unless(s > 95 && s < 105); 97 | 98 | fail_unless(hll_destroy(&h) == 0); 99 | } 100 | END_TEST 101 | 102 | START_TEST(test_hll_size) 103 | { 104 | hll_t h; 105 | fail_unless(hll_init(10, &h) == 0); 106 | 107 | double s = hll_size(&h); 108 | fail_unless(s == 0); 109 | 110 | fail_unless(hll_destroy(&h) == 0); 111 | } 112 | END_TEST 113 | 114 | START_TEST(test_hll_error_bound) 115 | { 116 | // Precision 14 -> variance of 1% 117 | hll_t h; 118 | fail_unless(hll_init(14, &h) == 0); 119 | 120 | char buf[100]; 121 | for (int i=0; i < 10000; i++) { 122 | fail_unless(sprintf((char*)&buf, "test%d", i)); 123 | hll_add(&h, (char*)&buf); 124 | } 125 | 126 | // Should be within 1% 127 | double s = hll_size(&h); 128 | fail_unless(s > 9900 && s < 10100); 129 | 130 | fail_unless(hll_destroy(&h) == 0); 131 | } 132 | END_TEST 133 | 134 | START_TEST(test_hll_precision_for_error) 135 | { 136 | fail_unless(hll_precision_for_error(1.0) == -1); 137 | fail_unless(hll_precision_for_error(0.0) == -1); 138 | fail_unless(hll_precision_for_error(0.02) == 12); 139 | fail_unless(hll_precision_for_error(0.01) == 14); 140 | fail_unless(hll_precision_for_error(0.005) == 16); 141 | } 142 | END_TEST 143 | 144 | 145 | START_TEST(test_hll_error_for_precision) 146 | { 147 | fail_unless(hll_error_for_precision(3) == 0); 148 | fail_unless(hll_error_for_precision(20) == 0); 149 | fail_unless(hll_error_for_precision(12) == .01625); 150 | fail_unless(hll_error_for_precision(10) == .0325); 151 | fail_unless(hll_error_for_precision(16) == .0040625); 152 | } 153 | END_TEST 154 | 155 | START_TEST(test_hll_bytes_for_precision) 156 | { 157 | fail_unless(hll_bytes_for_precision(3) == 0); 158 | fail_unless(hll_bytes_for_precision(20) == 0); 159 | fail_unless(hll_bytes_for_precision(12) == 3280); 160 | fail_unless(hll_bytes_for_precision(10) == 820); 161 | fail_unless(hll_bytes_for_precision(16) == 52432); 162 | } 163 | END_TEST 164 | 165 | --------------------------------------------------------------------------------