"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libinotifytools/src/test.c" between
inotify-tools-3.20.2.2.tar.gz and inotify-tools-3.20.11.0.tar.gz

About: inotify-tools offers commandline utilities relating to inotify (wait for or watch particular events on files).

test.c  (inotify-tools-3.20.2.2):test.c  (inotify-tools-3.20.11.0)
skipping to change at line 202 skipping to change at line 202
compare(inotifytools_filename_from_wd(2), 0); compare(inotifytools_filename_from_wd(2), 0);
EXIT EXIT
} }
void tst_inotifytools_snprintf() { void tst_inotifytools_snprintf() {
ENTER ENTER
verify((0 == mkdir(TEST_DIR, 0700)) || (EEXIST == errno)); verify((0 == mkdir(TEST_DIR, 0700)) || (EEXIST == errno));
verify(inotifytools_initialize()); verify(inotifytools_initialize());
verify(inotifytools_watch_file(TEST_DIR, IN_CLOSE)); verify(inotifytools_watch_file(TEST_DIR, IN_CLOSE));
#define BUFSZ 2048
#define RESET \ #define RESET \
do { \ do { \
memset(buf, 0, BUFSZ); \ memset(out.buf, 0, MAX_STRLEN); \
memset(test_event, 0, sizeof(struct inotify_event)); \ memset(test_event, 0, sizeof(struct inotify_event)); \
test_event->wd = inotifytools_wd_from_filename(TEST_DIR "/"); \ test_event->wd = inotifytools_wd_from_filename(TEST_DIR "/"); \
verify(test_event->wd >= 0); \ verify(test_event->wd >= 0); \
inotifytools_set_printf_timefmt(0); \ inotifytools_set_printf_timefmt(0); \
} while (0) } while (0)
char buf[BUFSZ]; struct nstring out;
char event_buf[4096]; char event_buf[4096];
struct inotify_event *test_event = (struct inotify_event *)event_buf; struct inotify_event *test_event = (struct inotify_event *)event_buf;
RESET; RESET;
test_event->mask = IN_ACCESS; test_event->mask = IN_ACCESS;
inotifytools_snprintf(buf, 1024, test_event, "Event %e %.e on %w %f %T"); inotifytools_snprintf(&out, MAX_STRLEN, test_event, "Event %e %.e on %w %f %
verify2(!strcmp(buf, "Event ACCESS ACCESS on " TEST_DIR "/ "), buf); T");
verify2(!strcmp(out.buf, "Event ACCESS ACCESS on " TEST_DIR "/ "), out.buf)
;
RESET; RESET;
test_event->mask = IN_ACCESS | IN_DELETE; test_event->mask = IN_ACCESS | IN_DELETE;
inotifytools_snprintf(buf, 1024, test_event, "Event %e %.e on %w %f %T"); inotifytools_snprintf(&out, MAX_STRLEN, test_event, "Event %e %.e on %w %f % T");
verify2( verify2(
!strcmp(buf, "Event ACCESS,DELETE ACCESS.DELETE on " TEST_DIR "/ ") || !strcmp(out.buf, "Event ACCESS,DELETE ACCESS.DELETE on " TEST_DIR "/ ")
!strcmp(buf, ||
!strcmp(out.buf,
"Event DELETE,ACCESS DELETE.ACCESS on " TEST_DIR "/ "), "Event DELETE,ACCESS DELETE.ACCESS on " TEST_DIR "/ "),
buf); out.buf);
RESET; RESET;
test_event->mask = IN_MODIFY; test_event->mask = IN_MODIFY;
inotifytools_snprintf(buf, 10, test_event, "Event %e %.e on %w %f %T"); inotifytools_snprintf(&out, 10, test_event, "Event %e %.e on %w %f %T");
verify2(!strcmp(buf, "Event MODI"), buf); verify2(!strcmp(out.buf, "Event MODI"), out.buf);
RESET; RESET;
test_event->mask = IN_ACCESS; test_event->mask = IN_ACCESS;
strcpy(test_event->name, "my_great_file"); strcpy(test_event->name, "my_great_file");
test_event->len = strlen(test_event->name) + 1; test_event->len = strlen(test_event->name) + 1;
inotifytools_snprintf(buf, 1024, test_event, "Event %e %.e on %w %f %T"); inotifytools_snprintf(&out, MAX_STRLEN, test_event, "Event %e %.e on %w %f %
verify2(!strcmp(buf, "Event ACCESS ACCESS on " TEST_DIR "/ my_great_file "), T");
buf); verify2(!strcmp(out.buf, "Event ACCESS ACCESS on " TEST_DIR "/ my_great_file
"),
out.buf);
RESET; RESET;
test_event->mask = IN_ACCESS; test_event->mask = IN_ACCESS;
inotifytools_set_printf_timefmt("%D%% %H:%M"); inotifytools_set_printf_timefmt("%D%% %H:%M");
{ {
char expected[1024]; char expected[MAX_STRLEN];
char timestr[512]; char timestr[512];
time_t now = time(0); time_t now = time(0);
strftime(timestr, 512, "%D%% %H:%M", localtime(&now)); strftime(timestr, 512, "%D%% %H:%M", localtime(&now));
snprintf(expected, 1024, "Event ACCESS ACCESS on %s/ %s", TEST_DIR, snprintf(expected, MAX_STRLEN, "Event ACCESS ACCESS on %s/ %s", TEST_DI R,
timestr); timestr);
inotifytools_snprintf(buf, 1024, test_event, inotifytools_snprintf(&out, MAX_STRLEN, test_event,
"Event %e %.e on %w %f %T"); "Event %e %.e on %w %f %T");
verify2(!strcmp(buf, expected), buf); verify2(!strcmp(out.buf, expected), out.buf);
} }
#undef BUFSZ
EXIT EXIT
} }
void watch_limit() { void watch_limit() {
ENTER ENTER
verify((0 == mkdir(TEST_DIR, 0700)) || (EEXIST == errno)); verify((0 == mkdir(TEST_DIR, 0700)) || (EEXIST == errno));
INFO("Warning, this test may take a while\n"); INFO("Warning, this test may take a while\n");
#define INNER_LIMIT 16000 #define INNER_LIMIT 16000
#define OUTER_LIMIT 5 #define OUTER_LIMIT 5
 End of changes. 14 change blocks. 
19 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)