- Timestamp:
- 04/18/11 16:25:46 (14 years ago)
- Location:
- test
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
test/Makefile
r180 r228 5 5 OPTS=-std=gnu99 -pedantic -Wall -ggdb 6 6 INC:=-I../trunk/include -I../trunk/src -I/usr/local/include 7 LIB=-L/usr/local/lib -lm -lpthread 7 LIB=-L/usr/local/lib -lm -lpthread -ltalloc 8 8 9 9 REGFI_THREADTEST=regfi-threadtest … … 14 14 15 15 deps: 16 cd ../trunk && $(MAKE) clean 17 cd ../trunk && $(MAKE) lib 16 cd ../trunk && scons libregfi 18 17 19 18 $(REGFI_THREADTEST): regfi-threadtest.o -
test/pyregfi-smoketest.py
r227 r228 5 5 import io 6 6 import time 7 import threading 7 8 import pyregfi 8 9 … … 189 190 pass 190 191 192 193 def threadIterMain(iter): 194 x = 0 195 try: 196 for k in iter: 197 #x += len(k.name) + len(k.subkeys) 198 pass 199 except Exception as e: 200 print("%s dying young: %s" % (threading.current_thread().name, repr(e))) 201 # Exceptions are thrown on iteration because python state gets out of 202 # whack. That's fine, because we're really just interested in finding 203 # segfaults. People should not use iterators without locks, but it 204 # should at least not segfault on them. 205 pass 206 print("%s finished" % threading.current_thread().name) 207 208 def iterMultithread(hive, fh): 209 num_threads = 10 210 iter = pyregfi.HiveIterator(hive) 211 threads = [] 212 for t in range(0,num_threads): 213 threads.append(threading.Thread(target=threadIterMain, args=(iter,))) 214 for t in threads: 215 t.start() 216 for t in threads: 217 t.join() 218 219 191 220 tests = { 192 221 "iterTallyNames":iterTallyNames, … … 197 226 "iterIterWalk":iterIterWalk, 198 227 "iterCallbackIO":iterCallbackIO, 228 "iterMultithread":iterMultithread, 199 229 } 200 230 -
test/regfi-threadtest.c
r185 r228 2 2 * A program to stress test regfi under multithreaded use. 3 3 * 4 * Copyright (C) 2005-201 0Timothy D. Morgan4 * Copyright (C) 2005-2011 Timothy D. Morgan 5 5 * Copyright (C) 2002 Richard Sharpe, rsharpe@richardsharpe.com 6 6 * … … 46 46 47 47 48 49 48 void traverseValueList(REGFI_ITERATOR* iter) 50 49 { 51 const REGFI_VK_REC* value; 52 53 value = regfi_iterator_first_value(iter); 54 while(value != NULL) 55 { 50 const REGFI_VK* value; 51 bool ret; 52 53 for(ret=regfi_iterator_first_value(iter); 54 ret; 55 ret=regfi_iterator_next_value(iter)) 56 { 57 value = regfi_iterator_cur_value(iter); 56 58 printMsgs(iter->f); 57 59 regfi_free_record(value); 58 value = regfi_iterator_next_value(iter);59 60 } 60 61 } … … 63 64 void traverseKeyTree(REGFI_ITERATOR* iter) 64 65 { 65 const REGFI_NK _REC* root = NULL;66 const REGFI_NK _REC* cur = NULL;67 const REGFI_NK _REC* sub = NULL;68 const REGFI_SK _REC* sk;66 const REGFI_NK* root = NULL; 67 const REGFI_NK* cur = NULL; 68 const REGFI_NK* sub = NULL; 69 const REGFI_SK* sk; 69 70 bool print_this = true; 70 71 71 72 root = cur = regfi_iterator_cur_key(iter); 72 sub = regfi_iterator_first_subkey(iter); 73 regfi_iterator_first_subkey(iter); 74 sub = regfi_iterator_cur_subkey(iter); 73 75 printMsgs(iter->f); 74 76 … … 86 88 { 87 89 /* We're done with this sub-tree, going up and hitting other branches. */ 90 regfi_free_record(cur); 88 91 if(!regfi_iterator_up(iter)) 89 92 { … … 95 98 /* fprintf(stderr, "%s\n", cur->keyname);*/ 96 99 printMsgs(iter->f); 97 sk = regfi_iterator_cur_sk(iter);98 printMsgs(iter->f);99 100 if(cur == NULL) 100 101 bailOut(REGLOOKUP_EXIT_DATAERR, "ERROR: unexpected NULL for key.\n"); 101 102 sub = regfi_iterator_next_subkey(iter); 102 sk = regfi_fetch_sk(iter->f, cur); 103 printMsgs(iter->f); 104 regfi_free_record(sk); 105 106 regfi_iterator_next_subkey(iter); 107 sub = regfi_iterator_cur_subkey(iter); 103 108 } 104 109 print_this = false; … … 108 113 * Let's move down and print this first sub-tree out. 109 114 */ 115 regfi_free_record(cur); 110 116 if(!regfi_iterator_down(iter)) 111 117 { … … 118 124 regfi_free_record(sub); 119 125 120 sub = regfi_iterator_first_subkey(iter); 126 regfi_iterator_first_subkey(iter); 127 sub = regfi_iterator_cur_subkey(iter); 121 128 printMsgs(iter->f); 122 129 print_this = true; … … 124 131 printMsgs(iter->f); 125 132 } while(!((cur == root) && (sub == NULL))); 133 regfi_free_record(root); 126 134 127 135 if(print_verbose) … … 138 146 regfi_log_set_mask(REGFI_LOG_INFO|REGFI_LOG_WARN|REGFI_LOG_ERROR); 139 147 140 iter = regfi_iterator_new((REGFI_FILE*)f , REGFI_ENCODING_ASCII);148 iter = regfi_iterator_new((REGFI_FILE*)f); 141 149 if(iter == NULL) 142 150 { … … 198 206 } 199 207 200 f = regfi_alloc(fd );208 f = regfi_alloc(fd, REGFI_ENCODING_ASCII); 201 209 if(f == NULL) 202 210 { … … 214 222 pthread_join(threads[i], NULL); 215 223 224 free(threads); 216 225 regfi_free(f); 217 226 close(fd);
Note: See TracChangeset
for help on using the changeset viewer.