diff options
author | Stan Cox <scox@redhat.com> | 2008-05-29 14:46:38 -0400 |
---|---|---|
committer | Stan Cox <scox@redhat.com> | 2008-05-29 14:46:38 -0400 |
commit | c39d889155d4c9365bd27691d22a92c447ced976 (patch) | |
tree | 64b56069b0435ac09564ba983bea154a9747bcbe | |
parent | ef63732e82dd7979dcf608ba6ed4528e150b47ac (diff) | |
download | systemtap-steved-c39d889155d4c9365bd27691d22a92c447ced976.tar.gz systemtap-steved-c39d889155d4c9365bd27691d22a92c447ced976.tar.xz systemtap-steved-c39d889155d4c9365bd27691d22a92c447ced976.zip |
SW5106 Remove old map and histogram formatting code
110 files changed, 19 insertions, 7133 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog index cc8bf1b0..c9cd07fc 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,18 @@ +2008-05-29 Stan Cox <scox@redhat.com> + + * map.c (print_keytype): Remove. + (print_valtype): Remove. + (_stp_map_printn): Remove. + (_stp_map_print): Remove. + (_stp_pmap_printn): Remove. + * stat-common.c (_stp_stat_print_valtype): Remove. + * stat.c (__stp_stat_print): Remove. + (_stp_stat_print_cpu): Remove. + (_stp_stat_print): Remove. + * Makefile: Delete. + * tests: Delete. + * probes: Delete. + 2008-05-28 David Smith <dsmith@redhat.com> * task_finder.c (__stp_utrace_attach_match_filename): Added diff --git a/runtime/Makefile b/runtime/Makefile deleted file mode 100644 index 22d25ff9..00000000 --- a/runtime/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# -# Makefile for SystemTap runtime and example probes -# - -all: - make -w -C stpd - cd probes; ./build - -relayfs: - make -w -C relayfs - -clean: - make -w -C relayfs clean - make -w -C stpd clean - cd probes; ./build clean diff --git a/runtime/map.c b/runtime/map.c index a436d7ed..bb221cd2 100644 --- a/runtime/map.c +++ b/runtime/map.c @@ -1,6 +1,6 @@ /* -*- linux-c -*- * Map Functions - * Copyright (C) 2005, 2006, 2007 Red Hat Inc. + * Copyright (C) 2005, 2006, 2007, 2008 Red Hat Inc. * * This file is part of systemtap, and is free software. You can * redistribute it and/or modify it under the terms of the GNU General @@ -631,130 +631,6 @@ void _stp_map_sortn(MAP map, int n, int keynum, int dir) } } -static int print_keytype (char *fmt, int type, key_data *kd) -{ - //dbug ("*fmt = %c\n", *fmt); - switch (type) { - case STRING: - if (*fmt != 's') - return 1; - _stp_print (kd->strp); - break; - case INT64: - if (*fmt == 'x') - _stp_printf("%llx", kd->val); - else if (*fmt == 'X') - _stp_printf("%llX", kd->val); - else if (*fmt == 'd') - _stp_printf("%lld", kd->val); - else if (*fmt == 'p') { -#if BITS_PER_LONG == 64 - _stp_printf("%016llx", kd->val); -#else - _stp_printf("%08llx", kd->val); -#endif - } else if (*fmt == 'P') - _stp_symbol_print ((unsigned long)kd->val); - else - return 1; - break; - default: - return 1; - break; - } - return 0; -} - -static void print_valtype (MAP map, char *fmt, struct map_node *ptr) -{ - switch (map->type) { - case STRING: - if (*fmt == 's') - _stp_print (_stp_get_str(ptr)); - break; - case INT64: - { - int64_t val = _stp_get_int64(ptr); - if (*fmt == 'x') - _stp_printf("%llx", val); - else if (*fmt == 'X') - _stp_printf("%llX", val); - else if (*fmt == 'd') - _stp_printf("%lld", val); - else if (*fmt == 'p') { -#if BITS_PER_LONG == 64 - _stp_printf("%016llx", val); -#else - _stp_printf("%08llx", val); -#endif - } else if (*fmt == 'P') - _stp_symbol_print ((unsigned long)val); - break; - } - case STAT: - { - stat *sd = _stp_get_stat(ptr); - _stp_stat_print_valtype (fmt, &map->hist, sd, 0); - break; - } - default: - break; - } -} - -/** Print a Map. - * Print a Map using a format string. - * - * @param map Map - * @param fmt @ref format_string - */ -void _stp_map_printn (MAP map, int n, const char *fmt) -{ - struct map_node *ptr; - int type, num; - key_data kd; - - if (n < 0) - return; - - foreach (map, ptr) { - char *f = (char *)fmt; - while (*f) { - f = next_fmt (f, &num); - if (num) { - /* key */ - kd = (*map->get_key)(ptr, num, &type); - if (type != END) - print_keytype (f, type, &kd); - } else { - /* value */ - print_valtype (map, f, ptr); - } - if (*f) - f++; - } - _stp_print_char ('\n'); - if (n && (--n <= 0)) - break; - } - _stp_print_char ('\n'); - _stp_print_flush(); -} - -/** Print a Map. - * Print a Map using a format string. - * - * @param map Map - * @param fmt @ref format_string - */ -#define _stp_map_print(map,fmt) _stp_map_printn(map,0,fmt) - -void _stp_pmap_printn_cpu (PMAP pmap, int n, const char *fmt, int cpu) -{ - MAP m = per_cpu_ptr (pmap->map, cpu); - _stp_map_printn (m, n, fmt); -} - static struct map_node *_stp_new_agg(MAP agg, struct hlist_head *ahead, struct map_node *ptr) { struct map_node *aptr; @@ -911,8 +787,8 @@ MAP _stp_pmap_agg (PMAP pmap) */ #define _stp_pmap_get_agg(pmap) (&pmap->agg) -#define _stp_pmap_printn(map,n,fmt) _stp_map_printn (_stp_pmap_agg(map), n, fmt) -#define _stp_pmap_print(map,fmt) _stp_map_printn(_stp_pmap_agg(map),0,fmt) +/* #define _stp_pmap_printn(map,n,fmt) _stp_map_printn (_stp_pmap_agg(map), n, fmt) */ +/* #define _stp_pmap_print(map,fmt) _stp_map_printn(_stp_pmap_agg(map),0,fmt) */ static void _new_map_clear_node (struct map_node *m) { diff --git a/runtime/probes/ChangeLog b/runtime/probes/ChangeLog deleted file mode 100644 index 47976f5c..00000000 --- a/runtime/probes/ChangeLog +++ /dev/null @@ -1,113 +0,0 @@ -2006-09-26 David Smith <dsmith@redhat.com> - - * bench/run_bench: Changed 'stpd' references to 'staprun'. - * bench/trans_bench: Ditto. - * where_func/README: Ditto. - -2005-11-08 Martin Hunt <hunt@redhat.com> - - * shellsnoop/shellsnoop.c: Updated to use new map API. - * where_func/kprobe_where_funct.c: Ditto. - * os_timer/os_timer.c (probe_start): Ditto. - * test4/test4.c: Ditto. - * scf/scf.c: Ditto. - -2005-09-08 Martin Hunt <hunt@redhat.com> - - * scf/scf.c (inst_smp_call_function): Add new verbose arg - to _stp_stack_sprint() call. - -2005-08-31 Martin Hunt <hunt@redhat.com> - - * Makefile.template: Remove KTA, KALLSYMS_LOOKUP, - and KALLSYMS_LOOKUP_NAME - -2005-08-19 Martin Hunt <hunt@redhat.com> - - * shellsnoop/shellsnoop.c: Remove STP_NETLINK_ONLY. - * stp: Deleted. Use stpd directly. - - -2005-08-01 Martin Hunt <hunt@redhat.com> - - * agg/stat1.c (probe_exit): Remove "static" - * agg/count1.c (probe_exit): Ditto. - * agg/count2.c (probe_exit): Ditto. - * bench/bench_io2.c (probe_exit): Ditto. - * bench/bench_io1.c (probe_exit): Ditto. - * bench/bench.c (probe_exit): Ditto. - * bench/bench_ret.c (probe_exit): Ditto. - * bench/bench_multi.c (probe_exit): Ditto. - * where_func/kprobe_where_funct.c (probe_exit): Ditto. - * test4/test4.c (probe_exit): Ditto. - * tasklet/stp_tasklet.c (probe_exit): Ditto. - * os_timer/os_timer.c (probe_exit): Ditto. - * scf/scf.c (probe_exit): Ditto. - -2005-07-28 Martin Hunt <hunt@redhat.com> - - * bench/ALL: Chnage to probe sys_getuid() and sys_getgid() - because those aren't used by stpd, unlike sys_read() and sys_write(). - -2005-07-11 Martin Hunt <hunt@redhat.com> - - * build_probe: Set RELAYFS correctly. - - * Makefile.template: Fix for RELAYFS. - - * stp: Moved here. All probes now use this copy. - - * ALL/stp: source the master copy of stp. - -2005-07-08 Martin Hunt <hunt@redhat.com> - - * ALL: Use new runtime.h. Change init_module() - to probe_start() and don't do transport calls. - Remove MODULE_LICENSE and cleanup_module(). - -2005-07-01 Martin Hunt <hunt@redhat.com> - - * Makefile.template (debug): New target. - - * build: Support "debug" target. - - * build_probe: Ditto. - -2005-06-28 Martin Hunt <hunt@redhat.com> - - * bench/bench_ret.c (inst_sys_write_ret): Fix prototype. - - * bench: New probe to do benchmarks. - -2005-06-23 Martin Hunt <hunt@redhat.com> - - * all probes: Modified to use latest changes to transport.h. - -2005-06-21 Martin Hunt <hunt@redhat.com> - - * build_probe (build): Add relay_flush and relay_switch_subbuf to the - list of undefines to ignore. - -2005-06-20 Tom Zanussi <zanussi@us.ibm.com> - - * added transport_mode, subbuf_size, n_subbufs to all - probes and changed _stp_transport_open() calls. - - * removed all obsolete params from stp scripts. - -2005-06-18 Martin Hunt <hunt@redhat.com> - - * build: Modified to use build_probe. - - * build_probe: New file. This does the work of building - a single probe or set of probes in a directory. - - * Makefile.template: New file. Template used by - build_probe to create Makefiles. - - * agg: New set of probes to test/demonstrate - Counter and Stat aggregations. - - * all probes modified for latest changes and new build - process. - diff --git a/runtime/probes/Makefile.template b/runtime/probes/Makefile.template deleted file mode 100644 index 5d770e95..00000000 --- a/runtime/probes/Makefile.template +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile -PWD := $(shell pwd) -RT := $(PWD)/../.. -KVERSION := $(shell uname -r) -KDIR := /lib/modules/$(KVERSION)/build include - -FLAGS := -I $(RT) RELAYFS - -DFLAGS := $(FLAGS) -D DEBUG - -obj-m := XXX.o - -default: - $(MAKE) V=1 -C $(KDIR) M=$(PWD) RT=$(RT) EXTRA_CFLAGS="$(FLAGS)" modules - -debug: - $(MAKE) V=1 -C $(KDIR) M=$(PWD) RT=$(RT) EXTRA_CFLAGS="$(DFLAGS)" modules - - -clean: - /bin/rm -rf *.o *.o.d *.ko *~ *.mod.c .*.cmd .tmp_versions diff --git a/runtime/probes/README b/runtime/probes/README deleted file mode 100644 index f3cd9fb2..00000000 --- a/runtime/probes/README +++ /dev/null @@ -1,10 +0,0 @@ -/** @dir probes -This directory contains working example probes that demonstrate and test -the runtime library. They are tested on i386 and x86_64. -*/ - -To build all probes, just type "./build" -To clean up, "./build clean" -To see a verbose build "./build -v" - -The same commands work in any probe subdirectory. diff --git a/runtime/probes/agg/README b/runtime/probes/agg/README deleted file mode 100644 index b48db1b8..00000000 --- a/runtime/probes/agg/README +++ /dev/null @@ -1,3 +0,0 @@ -/** @dir agg -Test probes to use the Counter and Stat aggregations. -*/ diff --git a/runtime/probes/agg/build b/runtime/probes/agg/build deleted file mode 100755 index f3e83244..00000000 --- a/runtime/probes/agg/build +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -../build_probe $* diff --git a/runtime/probes/agg/count1.c b/runtime/probes/agg/count1.c deleted file mode 100644 index 731b236b..00000000 --- a/runtime/probes/agg/count1.c +++ /dev/null @@ -1,102 +0,0 @@ -#define STP_NETLINK_ONLY -#define STP_NUM_STRINGS 1 - -#include "runtime.h" - -#include "counter.c" -#include "probes.c" - -MODULE_DESCRIPTION("SystemTap probe: count1"); -MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>"); - -Counter opens; -Counter reads; -Counter writes; -Counter sched; -Counter idle; - -static int inst_sys_open (struct kprobe *p, struct pt_regs *regs) -{ - _stp_counter_add (opens, 1); - return 0; -} - -static int inst_sys_read (struct kprobe *p, struct pt_regs *regs) -{ - _stp_counter_add (reads, 1); - return 0; -} - -static int inst_sys_write (struct kprobe *p, struct pt_regs *regs) -{ - _stp_counter_add (writes, 1); - return 0; -} - -static int inst_schedule(struct kprobe *p, struct pt_regs *regs) -{ - _stp_counter_add (sched, 1); - return 0; -} - -static int inst_idle_cpu(struct kprobe *p, struct pt_regs *regs) -{ - _stp_counter_add (idle, 1); - return 0; -} - -static struct kprobe stp_probes[] = { - { - .addr = "sys_open", - .pre_handler = inst_sys_open - }, - { - .addr = "sys_read", - .pre_handler = inst_sys_read - }, - { - .addr = "sys_write", - .pre_handler = inst_sys_write - }, - { - .addr = "schedule", - .pre_handler = inst_schedule - }, - { - .addr = "idle_cpu", - .pre_handler = inst_idle_cpu - }, -}; - -#define MAX_STP_ROUTINE (sizeof(stp_probes)/sizeof(struct kprobe)) - -int probe_start(void) -{ - opens = _stp_counter_init(); - reads = _stp_counter_init(); - writes = _stp_counter_init(); - sched = _stp_counter_init(); - idle = _stp_counter_init(); - - return _stp_register_kprobes (stp_probes, MAX_STP_ROUTINE); -} - -void probe_exit (void) -{ - int i; - - _stp_unregister_kprobes (stp_probes, MAX_STP_ROUTINE); - - for_each_cpu(i) - _stp_printf ("sched calls for cpu %d = %lld\n", i, _stp_counter_get_cpu(sched, i, 0)); - - _stp_print ("\n\n"); - - _stp_printf ("open calls: %lld\n", _stp_counter_get(opens, 0)); - _stp_printf ("read calls: %lld\n", _stp_counter_get(reads, 0)); - _stp_printf ("write calls: %lld\n", _stp_counter_get(writes, 0)); - _stp_printf ("sched calls: %lld\n", _stp_counter_get(sched, 0)); - _stp_printf ("idle calls: %lld\n", _stp_counter_get(idle, 0)); - _stp_print_flush(); -} - diff --git a/runtime/probes/agg/count2.c b/runtime/probes/agg/count2.c deleted file mode 100644 index 23987759..00000000 --- a/runtime/probes/agg/count2.c +++ /dev/null @@ -1,81 +0,0 @@ -#define STP_NETLINK_ONLY -#define STP_NUM_STRINGS 1 -#include "runtime.h" - -#include "counter.c" -#include "probes.c" - -MODULE_DESCRIPTION("SystemTap probe: count2"); -MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>"); - -Counter opens; -Counter reads; -Counter writes; -Counter read_bytes; -Counter write_bytes; - -asmlinkage long inst_sys_open (const char __user * filename, int flags, int mode) -{ - _stp_counter_add (opens, 1); - jprobe_return(); - return 0; -} - -asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t count) -{ - _stp_counter_add (reads, 1); - _stp_counter_add (read_bytes, count); - jprobe_return(); - return 0; -} - -asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, size_t count) -{ - _stp_counter_add (writes, 1); - _stp_counter_add (write_bytes, count); - jprobe_return(); - return 0; -} - -static struct jprobe stp_probes[] = { - { - .kp.addr = (kprobe_opcode_t *)"sys_open", - .entry = (kprobe_opcode_t *) inst_sys_open - }, - { - .kp.addr = (kprobe_opcode_t *)"sys_read", - .entry = (kprobe_opcode_t *) inst_sys_read - }, - { - .kp.addr = (kprobe_opcode_t *)"sys_write", - .entry = (kprobe_opcode_t *) inst_sys_write - }, -}; - -#define MAX_STP_ROUTINE (sizeof(stp_probes)/sizeof(struct jprobe)) - -int probe_start(void) -{ - opens = _stp_counter_init(); - reads = _stp_counter_init(); - writes = _stp_counter_init(); - read_bytes = _stp_counter_init(); - write_bytes = _stp_counter_init(); - - return _stp_register_jprobes (stp_probes, MAX_STP_ROUTINE); -} - -void probe_exit (void) -{ - int i; - - _stp_unregister_jprobes (stp_probes, MAX_STP_ROUTINE); - - _stp_printf ("open calls: %lld\n", _stp_counter_get(opens, 0)); - _stp_printf ("read calls: %lld\n", _stp_counter_get(reads, 0)); - _stp_printf ("read bytes: %lld\n", _stp_counter_get(read_bytes, 0)); - _stp_printf ("write calls: %lld\n", _stp_counter_get(writes, 0)); - _stp_printf ("write bytes: %lld\n", _stp_counter_get(write_bytes, 0)); - - _stp_print_flush(); -} diff --git a/runtime/probes/agg/stat1.c b/runtime/probes/agg/stat1.c deleted file mode 100644 index 4e0cf961..00000000 --- a/runtime/probes/agg/stat1.c +++ /dev/null @@ -1,72 +0,0 @@ -#define STP_NETLINK_ONLY -#define STP_NUM_STRINGS 1 -#include "runtime.h" -#include "stat.c" -#include "counter.c" -#include "probes.c" - -MODULE_DESCRIPTION("SystemTap probe: stat1"); -MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>"); - - -Counter opens; -Stat reads; -Stat writes; - -asmlinkage long inst_sys_open (const char __user * filename, int flags, int mode) -{ - _stp_counter_add (opens, 1); - jprobe_return(); - return 0; -} - -asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t count) -{ - _stp_stat_add (reads, count); - jprobe_return(); - return 0; -} - -asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, size_t count) -{ - _stp_stat_add (writes, count); - jprobe_return(); - return 0; -} - -static struct jprobe stp_probes[] = { - { - .kp.addr = (kprobe_opcode_t *)"sys_open", - .entry = (kprobe_opcode_t *) inst_sys_open - }, - { - .kp.addr = (kprobe_opcode_t *)"sys_read", - .entry = (kprobe_opcode_t *) inst_sys_read - }, - { - .kp.addr = (kprobe_opcode_t *)"sys_write", - .entry = (kprobe_opcode_t *) inst_sys_write - }, -}; - -#define MAX_STP_ROUTINE (sizeof(stp_probes)/sizeof(struct jprobe)) - -int probe_start(void) -{ - opens = _stp_counter_init(); - reads = _stp_stat_init(HIST_LOG,24); - writes = _stp_stat_init(HIST_LINEAR,0,1000,50); - - return _stp_register_jprobes (stp_probes, MAX_STP_ROUTINE); -} - -void probe_exit (void) -{ - _stp_unregister_jprobes (stp_probes, MAX_STP_ROUTINE); - - _stp_printf ("OPENS: %lld\n", _stp_counter_get(opens, 0)); - _stp_stat_print (reads, "READS: count:%C sum:%S avg:%A min:%m max:%M\n%H", 0); - _stp_stat_print (writes, "WRITES: count:%C sum:%S avg:%A min:%m max:%M\n%H", 0); - - _stp_print_flush(); -} diff --git a/runtime/probes/agg/targets b/runtime/probes/agg/targets deleted file mode 100644 index 614a00d2..00000000 --- a/runtime/probes/agg/targets +++ /dev/null @@ -1,3 +0,0 @@ -count1 -count2 -stat1 diff --git a/runtime/probes/bench/Makefile b/runtime/probes/bench/Makefile deleted file mode 100644 index 9154e3dc..00000000 --- a/runtime/probes/bench/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: ttest itest - -ttest: ttest.c - gcc -Wall -O3 -o ttest ttest.c - -itest: itest.c - gcc -Wall -O3 -o itest itest.c - -clean: - /bin/rm -f itest ttest stpd_cpu* xxx* diff --git a/runtime/probes/bench/README b/runtime/probes/bench/README deleted file mode 100644 index 04801a74..00000000 --- a/runtime/probes/bench/README +++ /dev/null @@ -1,18 +0,0 @@ -This is a benchmark program for the SystemTap Runtime. - -It works by instrumenting sys_uid() and sys_gid(). It calls each a million -times and measures how long it takes. Then it puts an empty kprobe on one and jprobe on the -other and measures that. Subtracting the difference between the two runs gives -the kprobe and jprobe overhead. The process is then repeated for more -complicated probes. - -To Start: - -1. Build the test program. -> gcc -O3 -o time time.c - -2. Run the benchmarks -> ./run_bench - - - diff --git a/runtime/probes/bench/bench.c b/runtime/probes/bench/bench.c deleted file mode 100644 index a00efa05..00000000 --- a/runtime/probes/bench/bench.c +++ /dev/null @@ -1,51 +0,0 @@ -#define STP_NETLINK_ONLY -#define STP_NUM_STRINGS 1 - -#include "runtime.h" -#include "probes.c" - -MODULE_DESCRIPTION("SystemTap probe: bench"); -MODULE_AUTHOR("Martin Hunt"); - -asmlinkage ssize_t inst_sys_getgid (unsigned int fd, const char __user * buf, size_t count) -{ - jprobe_return(); - return 0; -} - -static int inst_sys_getuid (struct kprobe *p, struct pt_regs *regs) -{ - return 0; -} - -static struct jprobe jp[] = { - { - .kp.addr = (kprobe_opcode_t *)"sys_getgid", - .entry = (kprobe_opcode_t *) inst_sys_getgid - }, -}; - -static struct kprobe kp[] = { - { - .addr = "sys_getuid", - .pre_handler = inst_sys_getuid - } -}; - -#define NUM_JPROBES (sizeof(jp)/sizeof(struct jprobe)) -#define NUM_KPROBES (sizeof(kp)/sizeof(struct kprobe)) - -int probe_start(void) -{ - int ret = _stp_register_jprobes (jp, NUM_JPROBES); - if (ret >= 0) - if ((ret = _stp_register_kprobes (kp, NUM_KPROBES)) < 0) - _stp_unregister_jprobes (jp, NUM_JPROBES); - return ret; -} - -void probe_exit (void) -{ - _stp_unregister_jprobes (jp, NUM_JPROBES); - _stp_unregister_kprobes (kp, NUM_KPROBES); -} diff --git a/runtime/probes/bench/bench_io1.c b/runtime/probes/bench/bench_io1.c deleted file mode 100644 index 8bdc4018..00000000 --- a/runtime/probes/bench/bench_io1.c +++ /dev/null @@ -1,46 +0,0 @@ -#define STP_NUM_STRINGS 1 - -#include "runtime.h" -#include "probes.c" - -MODULE_DESCRIPTION("SystemTap probe: bench_io1"); -MODULE_AUTHOR("Martin Hunt"); - -static int inst_sys_getuid (struct kprobe *p, struct pt_regs *regs) -{ - /* print 100 chars */ - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_print_flush(); - return 0; -} - -static int inst_sys_getgid (struct kprobe *p, struct pt_regs *regs) -{ - /* print 100 chars */ - _stp_print_cstr ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_print_flush(); - return 0; -} - -static struct kprobe kp[] = { - { - .addr = "sys_getuid", - .pre_handler = inst_sys_getuid - }, - { - .addr = "sys_getgid", - .pre_handler = inst_sys_getgid - } -}; - -#define NUM_KPROBES (sizeof(kp)/sizeof(struct kprobe)) - -int probe_start(void) -{ - return _stp_register_kprobes (kp, NUM_KPROBES); -} - -void probe_exit (void) -{ - _stp_unregister_kprobes (kp, NUM_KPROBES); -} diff --git a/runtime/probes/bench/bench_io2.c b/runtime/probes/bench/bench_io2.c deleted file mode 100644 index 14216913..00000000 --- a/runtime/probes/bench/bench_io2.c +++ /dev/null @@ -1,47 +0,0 @@ -#define STP_RELAYFS -#define STP_NUM_STRINGS 1 - -#include "runtime.h" -#include "probes.c" - -MODULE_DESCRIPTION("SystemTap probe: bench_io2"); -MODULE_AUTHOR("Martin Hunt"); - -static int inst_sys_getuid (struct kprobe *p, struct pt_regs *regs) -{ - /* print 100 chars */ - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_print_flush(); - return 0; -} - -static int inst_sys_getgid (struct kprobe *p, struct pt_regs *regs) -{ - /* print 100 chars */ - _stp_print_cstr ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_print_flush(); - return 0; -} - -static struct kprobe kp[] = { - { - .addr = "sys_getuid", - .pre_handler = inst_sys_getuid - }, - { - .addr = "sys_getgid", - .pre_handler = inst_sys_getgid - } -}; - -#define NUM_KPROBES (sizeof(kp)/sizeof(struct kprobe)) - -int probe_start(void) -{ - return _stp_register_kprobes (kp, NUM_KPROBES); -} - -void probe_exit (void) -{ - _stp_unregister_kprobes (kp, NUM_KPROBES); -} diff --git a/runtime/probes/bench/bench_io3.c b/runtime/probes/bench/bench_io3.c deleted file mode 100644 index a491edd9..00000000 --- a/runtime/probes/bench/bench_io3.c +++ /dev/null @@ -1,44 +0,0 @@ -#define STP_NUM_STRINGS 1 - -#include "runtime.h" -#include "probes.c" - -MODULE_DESCRIPTION("SystemTap probe: bench_io3"); -MODULE_AUTHOR("Martin Hunt"); - -static int inst_sys_getuid (struct kprobe *p, struct pt_regs *regs) -{ - /* print 1000 chars */ - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_print_flush(); - return 0; -} - - -static struct kprobe kp[] = { - { - .addr = "sys_getuid", - .pre_handler = inst_sys_getuid - }, -}; - -#define NUM_KPROBES (sizeof(kp)/sizeof(struct kprobe)) - -int probe_start(void) -{ - return _stp_register_kprobes (kp, NUM_KPROBES); -} - -void probe_exit (void) -{ - _stp_unregister_kprobes (kp, NUM_KPROBES); -} diff --git a/runtime/probes/bench/bench_io4.c b/runtime/probes/bench/bench_io4.c deleted file mode 100644 index a6b19ab5..00000000 --- a/runtime/probes/bench/bench_io4.c +++ /dev/null @@ -1,45 +0,0 @@ -#define STP_RELAYFS -#define STP_NUM_STRINGS 1 - -#include "runtime.h" -#include "probes.c" - -MODULE_DESCRIPTION("SystemTap probe: bench_io3"); -MODULE_AUTHOR("Martin Hunt"); - -static int inst_sys_getuid (struct kprobe *p, struct pt_regs *regs) -{ - /* print 1000 chars */ - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n"); - _stp_print_flush(); - return 0; -} - - -static struct kprobe kp[] = { - { - .addr = "sys_getuid", - .pre_handler = inst_sys_getuid - }, -}; - -#define NUM_KPROBES (sizeof(kp)/sizeof(struct kprobe)) - -int probe_start(void) -{ - return _stp_register_kprobes (kp, NUM_KPROBES); -} - -void probe_exit (void) -{ - _stp_unregister_kprobes (kp, NUM_KPROBES); -} diff --git a/runtime/probes/bench/bench_multi.c b/runtime/probes/bench/bench_multi.c deleted file mode 100644 index a6dc38a4..00000000 --- a/runtime/probes/bench/bench_multi.c +++ /dev/null @@ -1,73 +0,0 @@ -#define STP_NETLINK_ONLY -#define STP_NUM_STRINGS 1 - -#include "runtime.h" -#include "probes.c" - -MODULE_DESCRIPTION("SystemTap probe: bench_multi"); -MODULE_AUTHOR("Martin Hunt"); - -static int inst_sys_getuid1 (struct kprobe *p, struct pt_regs *regs) -{ - return 0; -} -static int inst_sys_getuid2 (struct kprobe *p, struct pt_regs *regs) -{ - return 0; -} - -static int inst_sys_getgid1 (struct kprobe *p, struct pt_regs *regs) -{ - return 0; -} -static int inst_sys_getgid2 (struct kprobe *p, struct pt_regs *regs) -{ - return 0; -} -static int inst_sys_getgid3 (struct kprobe *p, struct pt_regs *regs) -{ - return 0; -} -static int inst_sys_getgid4 (struct kprobe *p, struct pt_regs *regs) -{ - return 0; -} - -static struct kprobe kp[] = { - { - .addr = "sys_getuid", - .pre_handler = inst_sys_getuid1 - }, - { - .addr = "sys_getuid", - .pre_handler = inst_sys_getuid2 - }, - { - .addr = "sys_getgid", - .pre_handler = inst_sys_getgid1 - }, - { - .addr = "sys_getgid", - .pre_handler = inst_sys_getgid2 - }, - { - .addr = "sys_getgid", - .pre_handler = inst_sys_getgid3 - }, - { - .addr = "sys_getgid", - .pre_handler = inst_sys_getgid4 - } -}; - -#define NUM_KPROBES (sizeof(kp)/sizeof(struct kprobe)) - -int probe_start(void) -{ - return _stp_register_kprobes (kp, NUM_KPROBES); -} - -void probe_exit (void) -{ - _stp_unregister_kprobes (kp, NUM_KPROBES); -} diff --git a/runtime/probes/bench/bench_ret.c b/runtime/probes/bench/bench_ret.c deleted file mode 100644 index 40f2ddad..00000000 --- a/runtime/probes/bench/bench_ret.c +++ /dev/null @@ -1,61 +0,0 @@ -#define STP_NETLINK_ONLY -#define STP_NUM_STRINGS 1 -#define USE_RET_PROBES - -#include "runtime.h" -#include "probes.c" - -MODULE_DESCRIPTION("SystemTap probe: bench_ret"); -MODULE_AUTHOR("Martin Hunt"); - -static int inst_sys_getuid (struct kprobe *p, struct pt_regs *regs) -{ - return 0; -} - -static int inst_sys_getgid_ret (struct kretprobe_instance *ri, struct pt_regs *regs) -{ - return 0; -} - -static int inst_sys_getgid (struct kprobe *p, struct pt_regs *regs) -{ - return 0; -} - -static struct kretprobe kpr[] = { - { - .kp.addr = "sys_getuid", - .handler = inst_sys_getuid - }, - { - .kp.addr = "sys_getgid", - .handler = inst_sys_getgid_ret - } -}; - -static struct kprobe kp[] = { - { - .addr = "sys_getgid", - .pre_handler = inst_sys_getgid - } -}; - - -#define NUM_KPROBES (sizeof(kpr)/sizeof(struct kretprobe)) - -int probe_start(void) -{ - int ret = _stp_register_kretprobes (kpr, NUM_KPROBES); - if (ret >= 0) { - if ((ret = _stp_register_kprobes (kp, 1)) < 0) - _stp_unregister_kretprobes (kpr, NUM_KPROBES); - } - return ret; -} - -void probe_exit (void) -{ - _stp_unregister_kretprobes (kpr, NUM_KPROBES); - _stp_unregister_kprobes (kp, 1); -} diff --git a/runtime/probes/bench/build b/runtime/probes/bench/build deleted file mode 100755 index f3e83244..00000000 --- a/runtime/probes/bench/build +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -../build_probe $* diff --git a/runtime/probes/bench/check_modules b/runtime/probes/bench/check_modules deleted file mode 100755 index c3ab9ac3..00000000 --- a/runtime/probes/bench/check_modules +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -RELAYFS=`grep " relayfs_poll" /boot/System.map-\`uname -r\`` -if [ -z "$RELAYFS" ] -then - RELAYFS=`lsmod | grep relayfs` - if [ -z "$RELAYFS" ] - then - /sbin/insmod ../../relayfs/relayfs.ko - fi -fi - -if [ ! -d "/mnt/relay" ] -then - mkdir /mnt/relay -fi - -MOUNT=`mount | grep relayfs |awk '{print $1}'` -if [ "$MOUNT" != "relayfs" ] -then - mount -t relayfs relayfs /mnt/relay -fi - -STP_CONTROL=`lsmod | grep stp_control |awk '{print $1}'` -if [ "$STP_CONTROL" != "stp_control" ] -then - /sbin/insmod ../../transport/stp-control.ko -fi diff --git a/runtime/probes/bench/itest.c b/runtime/probes/bench/itest.c deleted file mode 100644 index 8ac11b8f..00000000 --- a/runtime/probes/bench/itest.c +++ /dev/null @@ -1,71 +0,0 @@ -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <sys/time.h> -#include <stdlib.h> -#include <sys/resource.h> -#include <unistd.h> - -typedef unsigned long long uint64; -struct rusage rstart; -struct timeval tstart, tstop; -uint64 ttime = 0; - -void start() -{ - gettimeofday (&tstart, NULL); - getrusage (RUSAGE_SELF, &rstart); -} - -uint64 usecs (struct timeval *tv) -{ - return tv->tv_sec * 1000000 + tv->tv_usec; -} - -uint64 stop() -{ - struct rusage rend; - getrusage (RUSAGE_SELF, &rend); - gettimeofday (&tstop, NULL); - uint64 utime = usecs(&rend.ru_utime) - usecs(&rstart.ru_utime); - uint64 stime = usecs(&rend.ru_stime) - usecs(&rstart.ru_stime); - ttime = usecs(&tstop) - usecs(&tstart); - return utime + stime; -} - -void usage(char *name) -{ - printf ("Usage %s [time]\nWhere \"time\" is millions of times to loop.\n", name); - exit(1); -} - -int main(int argc, char *argv[]) -{ - int i, n = 1; - uint64 nsecs; - - if (argc > 2) - usage(argv[0]); - - if (argc == 2) { - n = strtol(argv[1], NULL, 10); - if (n == 0) - usage(argv[0]); - } - - - start(); - for (i = 0; i < n * 1000000; i++) - getuid(); - - nsecs = stop() / (n * 1000); - - /* returns - nanosecs per call (user + system time) - elapsed usecs (real time) - */ - printf("%lld %.2f\n", nsecs, ttime/1000000.0); - - return 0; -} diff --git a/runtime/probes/bench/run_bench b/runtime/probes/bench/run_bench deleted file mode 100755 index a9442d3b..00000000 --- a/runtime/probes/bench/run_bench +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/tclsh -# -*- tcl -*- - -proc do_time {module n} { - global Failures - - # start kprobes - if {[catch {exec ../../stpd/staprun -rmq $module.ko > xxx &} pid]} { - puts $pid - exit -1 - } - - exec sleep 2 - - # get the timings while kprobes running - if {[catch {exec ./ttest $n} res2]} { - puts $res2 - exit -1 - } - - # terminate kprobes - if {[catch {exec kill -s SIGINT $pid} res]} { - puts $res - } - - exec sleep 2 - - # look for warnings - exec tail xxx >xxx.tail - if {[catch {open xxx.tail r} fd]} { - puts "Cannot open test output\n" - exit -1 - } - - set Failures 0 - while {[gets $fd line] >= 0} { - if {[regexp {^\033\[33mWARNING: \033\[0mThere were ([0-9]*) transport failures.} $line match var]} { - set Failures $var - break - } - } - close $fd - exec /bin/rm -f xxx xxx.out - return $res2 -} - -######## START HERE ########### - - -set nproc [exec grep ^processor /proc/cpuinfo | wc -l] -if {![catch {exec grep "physical id" /proc/cpuinfo} phyid]} { - foreach phy [split $phyid \n] { - set cpu($phy) 1 - } -} -set model [exec grep "model name" /proc/cpuinfo] -set model [lindex [split $model \n] 0] -set model [string range $model [expr [string first : $model]+1] end] -set model [string trimleft $model] - -puts "STP BENCH for [exec uname -r] on [exec uname -m]" -if {[file exists /etc/redhat-release]} { - puts [exec cat /etc/redhat-release] -} -puts "[exec uname -n]: [exec uptime]" -if {$nproc > 1} { - puts "processors: $nproc ([array size cpu] physical) $model" -} else { - puts "processors: $nproc $model" -} -set mem [split [exec cat /proc/meminfo] \n] -puts "[lindex $mem 0] [lindex $mem 1]" -puts "--------------------------------------" - -# get the timings without kprobes -if {[catch {exec ./ttest 4} res1]} { - puts $res1 - exit -1 -} - -set r_overhead [lindex $res1 0] -set w_overhead [lindex $res1 1] - -puts "function call overhead = $r_overhead ns" -puts "--------------------------------------" - -set res2 [do_time bench 4] -set t_kprobe [expr [lindex $res2 0] - $r_overhead] -set t_jprobe [expr [lindex $res2 1] - $w_overhead] - -puts "Jprobes overhead = $t_jprobe ns" -puts "Kprobes overhead = $t_kprobe ns" -puts "--------------------------------------" - -if {[file exists bench_ret.ko]} { - set res2 [do_time bench_ret 4] - set t_ret [expr [lindex $res2 0] - $r_overhead] - set t_entret [expr [lindex $res2 1] - $w_overhead] - - puts "Return probe overhead = $t_ret ns" - puts "Entry+Return probe overhead = $t_entret ns" - puts "--------------------------------------" -} - -set res2 [do_time bench_multi 4] -set t_k2 [expr [lindex $res2 0] - $r_overhead] -set t_k4 [expr [lindex $res2 1] - $w_overhead] - -puts "2 kprobes on same func = $t_k2 ns" -puts "4 kprobes on same func = $t_k4 ns" -puts "--------------------------------------" - -set res2 [do_time bench_io1 1] -# subtract function call overhead and kprobe overhead -set t_printf [expr [lindex $res2 0] - $r_overhead - $t_kprobe] -set t_print [expr [lindex $res2 1] - $w_overhead - $t_kprobe] - -puts "PROCFS" -puts "_stp_printf on 100 chars = $t_printf ns." -puts "_stp_print on 100 chars = $t_print ns." -puts "Transport failures: $Failures" -puts "--------------------------------------" -exec sleep 4 - -set res2 [do_time bench_io2 1] -# subtract function call overhead and kprobe overhead -set t_printf [expr [lindex $res2 0] - $r_overhead - $t_kprobe] -set t_print [expr [lindex $res2 1] - $w_overhead - $t_kprobe] - -puts "RELAYFS" -puts "_stp_printf on 100 chars = $t_printf ns." -puts "_stp_print on 100 chars = $t_print ns." -puts "Transport failures: $Failures" -puts "--------------------------------------" - -exec /bin/rm -f stpd_cpu* diff --git a/runtime/probes/bench/targets b/runtime/probes/bench/targets deleted file mode 100644 index 6c89c8d7..00000000 --- a/runtime/probes/bench/targets +++ /dev/null @@ -1,7 +0,0 @@ -bench -bench_io1 -bench_io2 -bench_io3 -bench_io4 -bench_ret -bench_multi diff --git a/runtime/probes/bench/trans_bench b/runtime/probes/bench/trans_bench deleted file mode 100755 index 12adbaff..00000000 --- a/runtime/probes/bench/trans_bench +++ /dev/null @@ -1,186 +0,0 @@ -#!/usr/bin/tclsh -# -*- tcl -*- - -proc do_time {module n buf} { - global Failures Filesize - - # start kprobes - if {[catch {exec ../../stpd/staprun -b $buf $module.ko > xxx &} pid]} { - puts $pid - exit -1 - } - - exec sleep 2 - - # get the timings while kprobes running - if {[catch {exec ./itest $n} res2]} { - puts "itest failed: $res2" - exit -1 - } - - exec sleep 4 - # terminate kprobes - if {[catch {exec kill -s SIGINT $pid} res]} { - puts "Kill failed: $res" - } - - exec sleep 4 - - # look for warnings - exec tail xxx >xxx.tail - if {[catch {open xxx.tail r} fd]} { - puts "Cannot open test output\n" - exit -1 - } - - set Failures 0 - while {[gets $fd line] >= 0} { - if {[regexp {^\033\[33mWARNING: \033\[0mThere were ([0-9]*) transport failures.} $line match var]} { - set Failures $var - break - } - } - close $fd - - set Filesize [file size xxx] - exec /bin/rm -f xxx xxx.out - return $res2 -} - -######## START HERE ########### - - -set nproc [exec grep ^processor /proc/cpuinfo | wc -l] -if {![catch {exec grep "physical id" /proc/cpuinfo} phyid]} { - foreach phy [split $phyid \n] { - set cpu($phy) 1 - } -} -set model [exec grep "model name" /proc/cpuinfo] -set model [lindex [split $model \n] 0] -set model [string range $model [expr [string first : $model]+1] end] -set model [string trimleft $model] - -puts "TRANS BENCH for [exec uname -r] on [exec uname -m]" -if {[file exists /etc/redhat-release]} { - puts [exec cat /etc/redhat-release] -} -puts "[exec uname -n]: [exec uptime]" -if {$nproc > 1} { - puts "processors: $nproc ([array size cpu] physical) $model" -} else { - puts "processors: $nproc $model" -} -set mem [split [exec cat /proc/meminfo] \n] -puts "[lindex $mem 0] [lindex $mem 1]" -puts "--------------------------------------" - -# load the modules -if {[catch {exec stp_check} res]} { - puts $res - exit -1 -} - -# warmup -exec ./itest 20 > /dev/null - -set res1 [do_time bench 1 1] -set call_overhead [lindex $res1 0] - -puts "Function call plus kprobe overhead = $call_overhead ns per call" -puts "--------------------------------------" - - -set max 5 -set n 1 -set buf 1 -while {$buf <= 64 && $n < $max} { - set Failures 0 - while {!$Failures && $n < $max} { - set res2 [do_time bench_io1 $n $buf] - set t_printf [expr [lindex $res2 0] - $call_overhead] - set total_print [lindex $res2 1] - puts "PROCFS with ${buf}MB buffers" - puts "_stp_printf on 100 chars = $t_printf ns / call system + user time." - if {$t_printf < 0} { - puts "res2=$res2" - exit - } - puts "_stp_printf of [expr $n * 100]MB in $total_print secs real time." - puts "Transfer rate = [format "%6.2f" [expr ($n * 100)/$total_print]] MB/sec" - puts "Transport failures: $Failures" - if {$Filesize != [expr $n * 100000000]} { - puts "WARNING: file size was $Filesize (expected [expr $n * 100000000])." - } - puts "--------------------------------------" - if {$Failures == 0} {incr n} - } - set buf [expr $buf + $buf] -} - -set max 5 -set n 1 -set buf 1 -while {$buf <= 64 && $n < $max} { - set Failures 0 - while {!$Failures && $n < $max} { - set res2 [do_time bench_io2 $n $buf] - set t_printf [expr [lindex $res2 0] - $call_overhead] - set total_print [lindex $res2 1] - puts "RELAYFS with ${buf}MB buffers" - puts "_stp_printf on 100 chars = $t_printf ns / call system + user time." - if {$t_printf < 0} { - puts "res2=$res2" - exit - } - puts "_stp_printf of [expr $n * 100]MB in $total_print secs real time." - puts "Transfer rate = [format "%6.2f" [expr ($n * 100)/$total_print]] MB/sec" - puts "Transport failures: $Failures" - if {$Filesize != [expr $n * 100000000]} { - puts "WARNING: file size was $Filesize (expected [expr $n * 100000000])." - } - puts "--------------------------------------" - if {$Failures == 0} {incr n} - } - set buf [expr $buf + $buf] -} - -set Failures 0 -set buf 1 -set res2 [do_time bench_io3 1 $buf] -set t_printf [expr [lindex $res2 0] - $call_overhead] -set total_print [lindex $res2 1] -puts "PROCFS with ${buf}MB buffers" -puts "_stp_printf on 1000 chars = $t_printf ns / call system + user time." -if {$t_printf < 0} { - puts "res2=$res2" - exit -} -puts "_stp_printf of 1GB in $total_print secs real time." -puts "Transfer rate = [format "%6.2f" [expr 1000/$total_print]] MB/sec" -puts "Transport failures: $Failures" -if {$Filesize != 1000000000} { - puts "WARNING: file size was $Filesize (expected 1000000000)." -} -puts "--------------------------------------" - -set Failures 0 -set buf 1 -set res2 [do_time bench_io4 1 $buf] -set t_printf [expr [lindex $res2 0] - $call_overhead] -set total_print [lindex $res2 1] -puts "RELAYFS with ${buf}MB buffers" -puts "_stp_printf on 1000 chars = $t_printf ns / call system + user time." -if {$t_printf < 0} { - puts "res2=$res2" - exit -} -puts "_stp_printf of 1GB in $total_print secs real time." -puts "Transfer rate = [format "%6.2f" [expr 1000/$total_print]] MB/sec" -puts "Transport failures: $Failures" -if {$Filesize != 1000000000} { - puts "WARNING: file size was $Filesize (expected 1000000000)." -} -puts "--------------------------------------" - -exec /bin/rm -f stpd_cpu* diff --git a/runtime/probes/bench/ttest.c b/runtime/probes/bench/ttest.c deleted file mode 100644 index 93b37c84..00000000 --- a/runtime/probes/bench/ttest.c +++ /dev/null @@ -1,74 +0,0 @@ -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <sys/time.h> -#include <stdlib.h> -#include <sys/resource.h> -#include <unistd.h> - -typedef unsigned long long uint64; -struct rusage rstart; - -void start() -{ - getrusage (RUSAGE_SELF, &rstart); -} - -uint64 usecs (struct timeval *tv) -{ - return tv->tv_sec * 1000000 + tv->tv_usec; -} - -uint64 stop() -{ - struct rusage rend; - getrusage (RUSAGE_SELF, &rend); - uint64 utime = usecs(&rend.ru_utime) - usecs(&rstart.ru_utime); - uint64 stime = usecs(&rend.ru_stime) - usecs(&rstart.ru_stime); - return utime + stime; -} - -void usage(char *name) -{ - printf ("Usage %s [time]\nWhere \"time\" is millions of times to loop.\n", name); - exit(1); -} - -int main(int argc, char *argv[]) -{ - int i, n = 1; - uint64 nsecs; - - if (argc > 2) - usage(argv[0]); - - if (argc == 2) { - n = strtol(argv[1], NULL, 10); - if (n == 0) - usage(argv[0]); - } - - /* large warmup time */ - for (i = 0; i < n * 1000000; i++) { - getuid(); - } - - start(); - for (i = 0; i < n * 1000000; i++) - getuid(); - - nsecs = stop() / (n * 1000); - - printf("%lld ", nsecs); - - start(); - for (i = 0; i < n * 1000000; i++) - getgid(); - - nsecs = stop() / (n * 1000); - - printf("%lld\n", nsecs); - - return 0; -} diff --git a/runtime/probes/build b/runtime/probes/build deleted file mode 100755 index ad65b0dc..00000000 --- a/runtime/probes/build +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/tclsh -# -*- tcl -*- - -# simple script to build each probe directory - -proc usage {} { - puts "Usage: build \[-v\] \[clean\] \[debug\]" - exit -} - -set clean "" -set verbose "" -set debug "" - -foreach arg $argv { - if {$arg == "clean"} { - set clean $arg - } elseif {$arg == "-v"} { - set verbose $arg - } elseif {$arg == "debug"} { - set debug $arg - } else { - usage - } -} - -set cmd "exec ../build_probe $verbose $clean" - -foreach filename [lsort [glob *]] { - if {$filename != "CVS" && [file isdirectory $filename]} { - cd $filename - if {[catch {exec ../build_probe $verbose $clean $debug} res]} { - puts $res - exit - } - puts $res - cd .. - } -} - diff --git a/runtime/probes/build_probe b/runtime/probes/build_probe deleted file mode 100755 index 7e3207b1..00000000 --- a/runtime/probes/build_probe +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/tclsh -# -*- tcl -*- - -proc usage {} { - puts "Usage: build \[-v\] \[clean\]" - exit -1 -} - -# use Makefile.template to generate a Makefile -proc create_makefile {target relayfs} { - if {[catch {open ../Makefile.template r} fd]} { - puts "ERROR opening ../Makefile.template" - exit -1 - } - if {[catch {open Makefile w} mfd]} { - puts "ERROR creating Makefile" - exit -1 - } - while {[gets $fd line] >= 0} { - if {[regsub XXX $line $target newline]} { - set line $newline - } - if {[regsub RELAYFS $line $relayfs newline]} { - set line $newline - } - puts $mfd $line - } - close $fd - close $mfd -} - -proc build {{target ""}} { - global clean verbose debug - if {$target == ""} { - set target [file tail [pwd]] - } - if {$clean} { - puts "Cleaning $target" - if {[catch {exec make clean >& compile.errors} res]} { - [exec cat compile.errors] - exit -1 - } - } else { - puts "Building $target" - - if {$debug == ""} { - if {[catch {exec make >& compile.errors} res]} { - puts "\n------------ Compile error in $target -------------------\n" - if {[catch {open compile.errors r} fd]} { - puts "Compile failed for unknown reasons" - exit -1 - } - while {[gets $fd line] >= 0} { - puts $line - } - close $fd - exit -1 - } - } else { - if {[catch {exec make debug >& compile.errors} res]} { - puts "\n------------ Compile error in $target -------------------\n" - if {[catch {open compile.errors r} fd]} { - puts "Compile failed for unknown reasons" - exit -1 - } - while {[gets $fd line] >= 0} { - puts $line - } - close $fd - exit -1 - } - } - - if {![catch {open compile.errors r} fd]} { - # search for warnings - set bad 0 - while {[gets $fd line] >= 0} { - if {$verbose} { - puts $line - } else { - if {[regexp {[^W]*([A-Za-z][A-Za-z0-9_]*)[^\"]*\"([^\"]*)} $line match warn var]} { - if {$warn == "Warning"} { - switch $var { - _stp_ctrl_unregister - - _stp_ctrl_register - - relay_subbufs_consumed - - _stp_ctrl_send - - relay_open - - relayfs_create_dir - - relayfs_remove_dir - - relay_flush - - relay_switch_subbuf - - relay_close {} - default { - if {$bad == 0} { - puts "\n------------ Unexpected Warnings in $target -------------------\n" - } - puts $line - set bad 1 - } - } - } - } - } - } - close $fd - } - if {$bad} { - exit -1 - } - } -} - -set clean 0 -set verbose 0 -set debug "" -foreach arg $argv { - if {$arg == "clean"} { - set clean 1 - } elseif {$arg == "-v"} { - set verbose 1 - } elseif {$arg == "debug"} { - set debug $arg - } elseif {$arg != ""} { - usage - } -} - -set relayfs "" -if {![file exists /lib/modules/[exec uname -r]/build/include/linux/relayfs_fs.h]} { - set relayfs {-I $(RT)/relayfs} -} - -if {![catch {open targets r} tfd]} { - while {[gets $tfd line] >= 0} { - set target [lindex $line 0] - create_makefile $target $relayfs - build $target - catch {exec /bin/rm Makefile} - } - close $tfd -} else { - if {![file exists Makefile]} { - puts "Now in [pwd]" - puts "ERROR: No targets file found and no Makefile either" - exit -1 - } - build -} - -puts "Done" -catch {exec /bin/rm compile.errors} - - diff --git a/runtime/probes/os_timer/build b/runtime/probes/os_timer/build deleted file mode 100755 index f3e83244..00000000 --- a/runtime/probes/os_timer/build +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -../build_probe $* diff --git a/runtime/probes/os_timer/os_timer.c b/runtime/probes/os_timer/os_timer.c deleted file mode 100644 index 4a80d02b..00000000 --- a/runtime/probes/os_timer/os_timer.c +++ /dev/null @@ -1,126 +0,0 @@ -/* Use the os timer as a poor-man's time based profiler for a UP system */ - -/* Demonstrates the beginnings of a generic framework for */ -/* asynchronous probes using the runtime */ - -/* @todo NOTE: the statement: regs = task_pt_regs(current); */ -/* isn't working in the way I would expect. The timer callback */ -/* happens, but I don't get a reasonable value in regs->eip */ -/* Can this routine be called during the timer callback? */ - -/* os includes */ -#include "linux/timer.h" - -/* How many strings to allocate. see strings.c. Default is 0. */ -#define STP_NUM_STRINGS 1 - -/* maximum size for a string. default is 2048 */ -#define STP_STRING_SIZE 2048 - -/* size of strings saved in maps */ -#define MAP_STRING_LENGTH 256 - -/* width of histograms. Default 50 */ -#define HIST_WIDTH 50 - -/* always include this. Put all non-map defines above it. */ -#include "runtime.h" - -/* @todo since we don't have aggregation maps yet, try regular maps */ -#define VALUE_TYPE INT64 -#define KEY1_TYPE STRING -#define KEY2_TYPE INT64 -#include "map-gen.c" - -#include "map.c" - -#include "stat.c" -#include "stack.c" - -MODULE_DESCRIPTION("SystemTap probe: os_timer"); -MODULE_AUTHOR("Charles Spirakis <charles.spirakis@intel.com>"); - -Stat timing; -MAP cur_addr; - -/* A generic asynchorous probe entry point */ -void inst_async(struct pt_regs *regs) -{ - u64 start; - u64 end; - unsigned long ip; - - rdtscll(start); - ip = REG_IP(regs); - - /* Create a map of interrupted addresses seen */ - /* really want a map of image name / address */ - _stp_map_add_sii(cur_addr, current->comm, ip, 1); - - /* Need _stp_stack() and _stp_ustack()? */ - /* _stp_image() and aggregation maps */ - - rdtscll(end); - _stp_stat_add(timing, end - start); -} - -static struct timer_list timer; - -/* Helper function to convert from os timer callback into */ -/* generic asynchronous entry point form */ -static void os_timer_callback(unsigned long val) -{ - struct pt_regs *regs; - - /* setup the next timeout now so it doesn't drift */ - /* due to processing the async probe code */ - mod_timer(&timer, jiffies + val); - - /* determine pt_regs from the kernel stack */ - /* @todo This doesn't seem to get a reasonable pt_regs pointer */ - /* based on the value of regs->eip. However, KSTK_EIP() in */ - /* include/asm/processor.h implies regs->eip is valid... */ - regs = task_pt_regs(current); - - /* Call the asynchronous probe with a ptregs struct */ - inst_async(regs); -} - -/* called when the module loads. */ -int probe_start(void) -{ - timing = _stp_stat_init(HIST_LINEAR, 0, 5000, 250); - - cur_addr = _stp_map_new_sii(1000); - - /* register the os_timer */ - init_timer(&timer); - - timer.expires = jiffies + 50; - timer.function = os_timer_callback; - - /* data is usd for defining when the next timeout shoud occur */ - timer.data = 50; - - add_timer(&timer); - return 0; -} - -void probe_exit (void) -{ - /* unregister the os_timer */ - del_timer_sync(&timer); - - /* print out any colledted data, etc */ - _stp_printf ("os timer done.\n"); - _stp_printf ("WARNING: Currently using task_pt_regs() to get the pt_regs struct\n"); - _stp_printf ("during the timer interrupt, but there seems to be issues with that...\n\n"); - _stp_stat_print (timing, "timing (cpu cycles): # calls:%C avg:%A min:%m max:%M\n%H", 0); - - _stp_print("Process\tIp\tCount\n"); - _stp_map_print (cur_addr, "%1s\t%2P\t%d"); - _stp_map_del(cur_addr); - - _stp_print_flush(); -} - diff --git a/runtime/probes/os_timer/stp b/runtime/probes/os_timer/stp deleted file mode 100755 index f3feee70..00000000 --- a/runtime/probes/os_timer/stp +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -source ../stp diff --git a/runtime/probes/os_timer/targets b/runtime/probes/os_timer/targets deleted file mode 100644 index 879d3afc..00000000 --- a/runtime/probes/os_timer/targets +++ /dev/null @@ -1 +0,0 @@ -os_timer diff --git a/runtime/probes/scf/README b/runtime/probes/scf/README deleted file mode 100644 index 39fcfda8..00000000 --- a/runtime/probes/scf/README +++ /dev/null @@ -1,12 +0,0 @@ -/** @dir scf -This example probe instruments smp_call_function(). - -It demonstrates using stack backtraces as map keys to compute the most -common path to a function. - -kernel.function("smp_call_function") -{ - traces[stack()] += 1 -} - -*/ diff --git a/runtime/probes/scf/build b/runtime/probes/scf/build deleted file mode 100755 index f3e83244..00000000 --- a/runtime/probes/scf/build +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -../build_probe $* diff --git a/runtime/probes/scf/scf.c b/runtime/probes/scf/scf.c deleted file mode 100644 index 0e29df43..00000000 --- a/runtime/probes/scf/scf.c +++ /dev/null @@ -1,50 +0,0 @@ -#define STP_NUM_STRINGS 1 -#include "runtime.h" - -#define MAP_STRING_LENGTH 512 - -#define VALUE_TYPE INT64 -#define KEY1_TYPE STRING -#include "map-gen.c" - -#include "map.c" -#include "sym.c" -#include "current.c" -#include "stack.c" -#include "probes.c" - -MODULE_DESCRIPTION("SystemTap probe: scf"); -MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>"); - -MAP map1; - -int inst_smp_call_function (struct kprobe *p, struct pt_regs *regs) -{ - String str = _stp_string_init (0); - _stp_stack_sprint (str, regs, 1); - _stp_map_add_si (map1, _stp_string_ptr(str), 1); - return 0; -} - -static struct kprobe stp_probes[] = { - { - .addr = (kprobe_opcode_t *)"smp_call_function", - .pre_handler = inst_smp_call_function - }, -}; - -#define MAX_STP_ROUTINE (sizeof(stp_probes)/sizeof(struct kprobe)) - -int probe_start(void) -{ - map1 = _stp_map_new_si (100); - return _stp_register_kprobes (stp_probes, MAX_STP_ROUTINE); -} - -void probe_exit (void) -{ - _stp_unregister_kprobes (stp_probes, MAX_STP_ROUTINE); - _stp_map_print (map1, "trace[%1s] = %d\n"); - _stp_map_del (map1); -} - diff --git a/runtime/probes/scf/targets b/runtime/probes/scf/targets deleted file mode 100644 index aafcca22..00000000 --- a/runtime/probes/scf/targets +++ /dev/null @@ -1 +0,0 @@ -scf diff --git a/runtime/probes/shellsnoop/README b/runtime/probes/shellsnoop/README deleted file mode 100644 index 70b5e614..00000000 --- a/runtime/probes/shellsnoop/README +++ /dev/null @@ -1,73 +0,0 @@ -/** @dir shellsnoop -Snoops on what commands are being run by shells. - -This is a translation of on an old dtr probe. It demonstrates maps, -lists, and how to use _stp_copy_argv_from_user() and _stp_strncpy_from_user(). - -Original dtr source: - -\verbatim -# shellsnoop.probe - snoop shell execution as it occurs. -# clone of dtrace shellsnoop example - -global { - long @pids[long]; -} - -probe do_execve:entry { - char __user *vstr; - char str[256]; - int len; - - /* watch shells only */ - /* FIXME: detect more shells, like csh, tcsh, zsh */ - - if (!strcmp(current->comm,"bash") || !strcmp(current->comm,"sh") || !strcmp(current->comm, "zsh") - || !strcmp(current->comm, "tcsh") || !strcmp(current->comm, "pdksh")) - { - dlog ("%d\t%d\t%d\t%s ", current->uid, current->pid, current->parent->pid, filename); - @pids[current->pid] = 1; - - /* print out argv, ignoring argv[0] */ - if (argv) argv++; - while (argv != NULL) - { - if (get_user (vstr, argv)) - break; - if (!vstr) - break; - len = dtr_strncpy_from_user(str, vstr, 256); - str[len] = 0; - printk ("%s ", str); - argv++; - } - printk ("\n"); - } -} - -# use filp_open because copy_from_user not needed there -probe filp_open:entry { - if (@pids[current->pid]) - dlog ("%d\t%d\t%s\tO %s\n", current->pid, current->parent->pid, current->comm, filename); -} - -probe sys_read:entry { - if (@pids[current->pid]) - dlog ("%d\t%d\t%s\tR %d\n", current->pid, current->parent->pid, current->comm, fd); -} - -probe sys_write:entry { - size_t len; - char str[256]; - if (@pids[current->pid]) - { - if (count < 64) len = count; - else len = 64; - if (len = dtr_strncpy_from_user(str, buf, len)) { - str[len] = 0; - dlog ("%d\t%d\t%s\tW %s\n", current->pid, current->parent->pid, current->comm, str); - } - } -} -\endverbatim -*/ diff --git a/runtime/probes/shellsnoop/build b/runtime/probes/shellsnoop/build deleted file mode 100755 index f3e83244..00000000 --- a/runtime/probes/shellsnoop/build +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -../build_probe $* diff --git a/runtime/probes/shellsnoop/shellsnoop.c b/runtime/probes/shellsnoop/shellsnoop.c deleted file mode 100644 index dd0c81b9..00000000 --- a/runtime/probes/shellsnoop/shellsnoop.c +++ /dev/null @@ -1,161 +0,0 @@ -//#define STP_RELAYFS -#define STP_NUM_STRINGS 1 -#define STP_STRING_SIZE 8192 -#include "runtime.h" - -#define VALUE_TYPE INT64 -#define KEY1_TYPE INT64 -#include "map-gen.c" - -#define VALUE_TYPE STRING -#define KEY1_TYPE INT64 -#include "map-gen.c" - -#include "map.c" -#include "copy.c" -#include "probes.c" - -MODULE_DESCRIPTION("SystemTap probe: shellsnoop"); -MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>"); - -MAP pids, arglist ; - -void _stp_copy_argv_from_user (MAP list, char __user *__user *argv) -{ - char str[128]; - char __user *vstr; - int len, i = 0; - - if (argv) - argv++; - - while (argv != NULL) { - if (get_user (vstr, argv)) - break; - - if (vstr == NULL) - break; - - len = _stp_strncpy_from_user(str, vstr, 128); - str[len] = 0; - _stp_map_set_is (list, i++, str); - argv++; - } -} - -int inst_do_execve (char * filename, char __user *__user *argv, char __user *__user *envp, struct pt_regs * regs) -{ - struct map_node *ptr; - - /* watch shells only */ - /* FIXME: detect more shells, like csh, tcsh, zsh */ - - if (!strcmp(current->comm,"bash") || !strcmp(current->comm,"sh") || !strcmp(current->comm, "zsh") - || !strcmp(current->comm, "tcsh") || !strcmp(current->comm, "pdksh")) - { - _stp_printf ("%d\t%d\t%d\t%s ", current->uid, current->pid, current->parent->pid, filename); - - _stp_map_set_ii (pids, current->pid, 1); - - _stp_map_clear (arglist); - _stp_copy_argv_from_user (arglist, argv); - - foreach (arglist, ptr) - _stp_printf ("%s ", _stp_get_str(ptr)); - _stp_print("\n"); - - _stp_print_flush(); - } - jprobe_return(); - return 0; -} - -struct file * inst_filp_open (const char * filename, int flags, int mode) -{ - if (_stp_map_get_ii (pids, current->pid)) { - _stp_printf ("%d\t%d\t%s\tO %s\n", current->pid, current->parent->pid, current->comm, filename); - _stp_print_flush(); - } - jprobe_return(); - return 0; -} - -asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t count) -{ - if (_stp_map_get_ii (pids, current->pid)) { - _stp_printf ("%d\t%d\t%s\tR %d\n", current->pid, current->parent->pid, current->comm, fd); - _stp_print_flush(); - } - jprobe_return(); - return 0; -} - -asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, size_t count) -{ - if (_stp_map_get_ii (pids, current->pid)) { - String str = _stp_string_init (0); - _stp_string_from_user(str, buf, count); - _stp_printf ("%d\t%d\t%s\tW %s", current->pid, current->parent->pid, - current->comm, _stp_string_ptr(str)); - _stp_print_flush(); - } - - jprobe_return(); - return 0; -} - -static struct jprobe stp_probes[] = { - { - .kp.addr = (kprobe_opcode_t *)"do_execve", - .entry = (kprobe_opcode_t *) inst_do_execve - }, - { - .kp.addr = (kprobe_opcode_t *)"filp_open", - .entry = (kprobe_opcode_t *) inst_filp_open - }, - { - .kp.addr = (kprobe_opcode_t *)"sys_read", - .entry = (kprobe_opcode_t *) inst_sys_read - }, - { - .kp.addr = (kprobe_opcode_t *)"sys_write", - .entry = (kprobe_opcode_t *) inst_sys_write - }, -}; - -#define MAX_STP_ROUTINE (sizeof(stp_probes)/sizeof(struct jprobe)) - - -int probe_start(void) -{ - int ret; - - /* now initialize any data or variables */ - pids = _stp_map_new_ii(10000); - arglist = _stp_map_new_is (10); - - /* now we are ready to enable the probes */ - ret = _stp_register_jprobes (stp_probes, MAX_STP_ROUTINE); - - if (ret < 0) { - _stp_map_del (pids); - _stp_map_del (arglist); - return ret; - } - - _stp_printf("instrumentation is enabled... %s\n", __this_module.name); - _stp_print_flush(); - return ret; -} - - -void probe_exit (void) -{ - _stp_unregister_jprobes (stp_probes, MAX_STP_ROUTINE); - _stp_map_del (pids); - _stp_map_del (arglist); - _stp_printf("\nDropped %d packets\n", atomic_read(&_stp_transport_failures)); - _stp_print_flush(); -} - - diff --git a/runtime/probes/shellsnoop/targets b/runtime/probes/shellsnoop/targets deleted file mode 100644 index fdd0d724..00000000 --- a/runtime/probes/shellsnoop/targets +++ /dev/null @@ -1 +0,0 @@ -shellsnoop diff --git a/runtime/probes/tasklet/README b/runtime/probes/tasklet/README deleted file mode 100644 index 8507ad9b..00000000 --- a/runtime/probes/tasklet/README +++ /dev/null @@ -1,9 +0,0 @@ -/** @dir tasklet -Sample probe in a tasklet. Useful for interrupt context testing. - -\verbatim -> make -> ./stp stp_tasklet.ko -\endverbatim - -*/ diff --git a/runtime/probes/tasklet/build b/runtime/probes/tasklet/build deleted file mode 100755 index f3e83244..00000000 --- a/runtime/probes/tasklet/build +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -../build_probe $* diff --git a/runtime/probes/tasklet/stp_tasklet.c b/runtime/probes/tasklet/stp_tasklet.c deleted file mode 100644 index f47fea9e..00000000 --- a/runtime/probes/tasklet/stp_tasklet.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Framework for putting a jprobe in a tasklet. */ -/* Useful for testing probes in interrupt context. */ -/* Doesn't do anything useful as is. Put test code in the inst func */ - -#define STP_NETLINK_ONLY -#define STP_NUM_STRINGS 1 - -#include "runtime.h" -#include "probes.c" - -MODULE_DESCRIPTION("test jprobes of tasklets"); -MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>"); - -void inst__rcu_process_callbacks(struct rcu_ctrlblk *rcp, - struct rcu_state *rsp, struct rcu_data *rdp) -{ - _stp_printf ("count=%d irqs_disabled=%d in_interrupt=%d in_irq=%d", - preempt_count(), irqs_disabled(), in_interrupt(), in_irq()); - _stp_print_flush(); - jprobe_return(); -} - -static struct jprobe stp_probes[] = { - { - .kp.addr = (kprobe_opcode_t *)"__rcu_process_callbacks", - .entry = (kprobe_opcode_t *) inst__rcu_process_callbacks - }, -}; -#define MAX_STP_PROBES (sizeof(stp_probes)/sizeof(struct jprobe)) - -int probe_start(void) -{ - return _stp_register_jprobes (stp_probes, MAX_STP_PROBES); -} - -void probe_exit (void) -{ - _stp_unregister_jprobes (stp_probes, MAX_STP_PROBES); -} - diff --git a/runtime/probes/tasklet/targets b/runtime/probes/tasklet/targets deleted file mode 100644 index 236dbd95..00000000 --- a/runtime/probes/tasklet/targets +++ /dev/null @@ -1 +0,0 @@ -stp_tasklet diff --git a/runtime/probes/test4/README b/runtime/probes/test4/README deleted file mode 100644 index 75d4be10..00000000 --- a/runtime/probes/test4/README +++ /dev/null @@ -1,24 +0,0 @@ -/** @dir test4 -This example probe tracks file opens, reads and writes. -It demonstrates maps, stats, and iterators. - -This is a translation of on an old dtr probe. Original source is -\verbatim -global { - long @opens[string]; - sum @reads[string], @writes[string]; -} - -probe sys_open:entry { - @opens[current->comm]++; -} - -probe sys_read:entry { - @reads[current->comm] << count; -} - -probe sys_write:entry { - @writes[current->comm] << count; -} -\endverbatim -*/ diff --git a/runtime/probes/test4/build b/runtime/probes/test4/build deleted file mode 100755 index f3e83244..00000000 --- a/runtime/probes/test4/build +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -../build_probe $* diff --git a/runtime/probes/test4/targets b/runtime/probes/test4/targets deleted file mode 100644 index d234c5e0..00000000 --- a/runtime/probes/test4/targets +++ /dev/null @@ -1 +0,0 @@ -test4 diff --git a/runtime/probes/test4/test4.c b/runtime/probes/test4/test4.c deleted file mode 100644 index 56027186..00000000 --- a/runtime/probes/test4/test4.c +++ /dev/null @@ -1,79 +0,0 @@ -#define STP_NUM_STRINGS 1 -#include "runtime.h" - -#define VALUE_TYPE INT64 -#define KEY1_TYPE STRING -#include "map-gen.c" - -#define VALUE_TYPE STAT -#define KEY1_TYPE STRING -#include "map-gen.c" - -#include "map.c" -#include "probes.c" - -MODULE_DESCRIPTION("SystemTap probe: test4"); -MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>"); - - -MAP opens, reads, writes; - -asmlinkage long inst_sys_open (const char __user * filename, int flags, int mode) -{ - _stp_map_add_si (opens, current->comm, 1); - jprobe_return(); - return 0; -} - -asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t count) -{ - _stp_map_add_sx (reads, current->comm, count); - jprobe_return(); - return 0; -} - -asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, size_t count) -{ - _stp_map_add_sx (writes, current->comm, count); - jprobe_return(); - return 0; -} - -static struct jprobe stp_probes[] = { - { - .kp.addr = (kprobe_opcode_t *)"sys_open", - .entry = (kprobe_opcode_t *) inst_sys_open - }, - { - .kp.addr = (kprobe_opcode_t *)"sys_read", - .entry = (kprobe_opcode_t *) inst_sys_read - }, - { - .kp.addr = (kprobe_opcode_t *)"sys_write", - .entry = (kprobe_opcode_t *) inst_sys_write - }, -}; - -#define MAX_STP_ROUTINE (sizeof(stp_probes)/sizeof(struct jprobe)) - -int probe_start(void) -{ - opens = _stp_map_new_si (1000); - reads = _stp_map_new_sx (1000, HIST_LOG, 12); - writes = _stp_map_new_sx (1000, HIST_LOG, 12); - return _stp_register_jprobes (stp_probes, MAX_STP_ROUTINE); -} - -void probe_exit (void) -{ - _stp_unregister_jprobes (stp_probes, MAX_STP_ROUTINE); - - _stp_map_print (opens,"%d opens by process \"%1s\""); - _stp_map_print (reads,"reads by process \"%1s\": %C. Total bytes=%S. Average: %A\n%H"); - _stp_map_print (writes,"writes by process \"%1s\": %C. Total bytes=%S. Average: %A\n%H"); - _stp_printf("\nDropped %d packets\n", atomic_read(&_stp_transport_failures)); - _stp_print_flush(); - _stp_map_del (opens); - _stp_map_del (reads); - _stp_map_del (writes); -} diff --git a/runtime/probes/where_func/README b/runtime/probes/where_func/README deleted file mode 100644 index 78009566..00000000 --- a/runtime/probes/where_func/README +++ /dev/null @@ -1,29 +0,0 @@ -/** @dir where_func -This is a silly little instrumentation routine to instrument functions -entry by name. It makes use of the SystemTap runtime libraries to break -down the number of times the function by caller. - -It demonstrates kprobes, passing a module parameter, using the print buffer, -and using _stp_print_symbol() to map the addresses back to locations -in functions. - -By default it instruments schedule(). - -The instrumentation module is built by having the kernel that is going -to be instrumented currently on the machine and doing -\code -./build -\endcode -The instrumentation is inserted as root with: -\code -/sbin/insmod kprobe_funct_where.ko funct_name=function_name -\endcode -The instrumentation is removed as root with: -\code -/sbin/rmmod kprobe_funct_where -\endcode --Will Cohen - -Note that this module is broken now because we don't pass the module parameter -tp staprun. FIXME -*/ diff --git a/runtime/probes/where_func/build b/runtime/probes/where_func/build deleted file mode 100755 index f3e83244..00000000 --- a/runtime/probes/where_func/build +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -../build_probe $* diff --git a/runtime/probes/where_func/kprobe_where_funct.c b/runtime/probes/where_func/kprobe_where_funct.c deleted file mode 100644 index 680dabd8..00000000 --- a/runtime/probes/where_func/kprobe_where_funct.c +++ /dev/null @@ -1,62 +0,0 @@ -/* kprobe_where_funct.c - this is a simple module to get information about calls to a function - that is passed as a module option - Will Cohen -*/ - -#define STP_NUM_STRINGS 1 - -#include "runtime.h" - -#define VALUE_TYPE INT64 -#define KEY1_TYPE INT64 -#include "map-gen.c" - -#include "map.c" -#include "probes.c" -#include "sym.c" -#include "current.c" - -MODULE_DESCRIPTION("SystemTap probe: where_func"); -MODULE_AUTHOR("Will Cohen and Martin Hunt"); - -static char default_name[] = "schedule"; -static char *funct_name = default_name; -module_param(funct_name, charp, 0); -MODULE_PARM_DESC(funct_name, "function entry name.\n"); - -MAP funct_locations; - -static int inst_funct(struct kprobe *p, struct pt_regs *regs) -{ - long ret_addr = _stp_ret_addr(regs); - _stp_map_add_ii(funct_locations, ret_addr, 1); - return 0; -} - -/*For each probe you need to allocate a kprobe structure*/ -static struct kprobe kp[] = { - { - .addr = default_name, - .pre_handler = inst_funct, - } -}; -#define MAX_KPROBES (sizeof(kp)/sizeof(struct kprobe)) - -int probe_start(void) -{ - funct_locations = _stp_map_new_ii (1000); - - if (funct_name) - kp[0].addr = funct_name; - - return _stp_register_kprobes (kp, MAX_KPROBES); -} - -void probe_exit (void) -{ - _stp_unregister_kprobes (kp, MAX_KPROBES); - - _stp_map_print (funct_locations, "Count: %d\tCaller: %1P"); - _stp_map_del(funct_locations); -} diff --git a/runtime/probes/where_func/targets b/runtime/probes/where_func/targets deleted file mode 100644 index 7e8e4cf1..00000000 --- a/runtime/probes/where_func/targets +++ /dev/null @@ -1 +0,0 @@ -kprobe_where_funct diff --git a/runtime/stat-common.c b/runtime/stat-common.c index a62297bf..7dabe708 100644 --- a/runtime/stat-common.c +++ b/runtime/stat-common.c @@ -1,6 +1,6 @@ /* -*- linux-c -*- * common stats functions for aggragations and maps - * Copyright (C) 2005, 2006, 2007 Red Hat Inc. + * Copyright (C) 2005, 2006, 2007, 2008 Red Hat Inc. * * This file is part of systemtap, and is free software. You can * redistribute it and/or modify it under the terms of the GNU General @@ -299,39 +299,6 @@ static void _stp_stat_print_histogram (Hist st, stat *sd) _stp_print_flush(); } -static void _stp_stat_print_valtype (char *fmt, Hist st, stat *sd, int cpu) -{ - switch (*fmt) { - case 'C': - _stp_printf("%lld", sd->count); - break; - case 'm': - _stp_printf("%lld", sd->min); - break; - case 'M': - _stp_printf("%lld", sd->max); - break; - case 'S': - _stp_printf("%lld", sd->sum); - break; - case 'A': - { - int64_t avg = 0; - if (sd->count) - avg = _stp_div64 (NULL, sd->sum, sd->count); - _stp_printf("%lld", avg); - break; - } - case 'H': - _stp_stat_print_histogram (st, sd); - _stp_print_flush(); - break; - case 'c': - _stp_printf("%d", cpu); - break; - } -} - static void __stp_stat_add (Hist st, stat *sd, int64_t val) { int n; diff --git a/runtime/stat.c b/runtime/stat.c index f8b5f018..8bd7bf12 100644 --- a/runtime/stat.c +++ b/runtime/stat.c @@ -237,56 +237,6 @@ stat *_stp_stat_get (Stat st, int clear) } -static void __stp_stat_print (char *fmt, Stat st, stat *sd, int cpu) -{ - int num; - char *f = (char *)fmt; - while (*f) { - f = next_fmt (f, &num); - _stp_stat_print_valtype (f, &st->hist, sd, cpu); - if (*f) - f++; - } - _stp_print_char('\n'); - _stp_print_flush(); -} - -/** Print per-cpu Stats. - * Prints the Stats for each CPU. - * - * @param st Stat - * @param fmt @ref format_string - * @param clear Set if you want the data cleared after the read. Useful - * for polling. - */ -void _stp_stat_print_cpu (Stat st, char *fmt, int clear) -{ - int i; - for_each_cpu(i) { - stat *sd = per_cpu_ptr (st->sd, i); - STAT_LOCK(sd); - __stp_stat_print (fmt, st, sd, i); - if (clear) - _stp_stat_clear_data (st, sd); - STAT_UNLOCK(sd); - } -} - -/** Print Stats. - * Prints the Stats. - * - * @param st Stat - * @param fmt @ref format_string - * @param clear Set if you want the data cleared after the read. Useful - * for polling. - */ -void _stp_stat_print (Stat st, char *fmt, int clear) -{ - stat *agg = _stp_stat_get(st, clear); - __stp_stat_print (fmt, st, agg, 0); - STAT_UNLOCK(agg); -} - /** Clear Stats. * Clears the Stats. * diff --git a/runtime/tests/ChangeLog b/runtime/tests/ChangeLog deleted file mode 100644 index 38634d0f..00000000 --- a/runtime/tests/ChangeLog +++ /dev/null @@ -1,112 +0,0 @@ -2006-01-25 Martin Hunt <hunt@redhat.com> - - * agg/stats.c (main): Delete Stats when done. - -2005-12-08 Martin Hunt <hunt@redhat.com> - - * maps/map.test: Add size test. - * pmaps/pmap.test: Add size test. - -2005-12-07 Martin Hunt <hunt@redhat.com> - - * agg/agg.test: Adjust results to match - the more compact histogram format. - - * pmaps/*.c: Change pmap type from MAP to PMAP. - - * pmaps/pmap.test: Adjust results to match - the more compact histogram format. - - * maps/map.test: Adjust results to match - the more compact histogram format. - -2005-11-28 Martin Hunt <hunt@redhat.com> - - * pmaps/pmap.test: Add ix_log and ix_none. - * pmaps/ix_log.c: Test log histograms. - * pmaps/ix_none.c: Test no histograms. - -2005-11-10 Martin Hunt <hunt@redhat.com> - * pmaps/ix2.c: New test. Test _stp_pmap_get_*(). - * pmaps/iii3.c: New test. Test _stp_pmap_get_*(). - * pmaps/pmap.test: Update. - -2005-11-10 Martin Hunt <hunt@redhat.com> - * pmaps/ii2.c: New test of maps and pmaps with the same keysym. - * pmaps/pmap.test: Update. - -2005-11-09 Martin Hunt <hunt@redhat.com> - - * maps/sort2.c: New file. - * maps/sort_stat.c: New file. - * maps/map.test: Update - -2005-11-08 Martin Hunt <hunt@redhat.com> - - * maps/map.test: Remove old map API tests. - * maps/ii2.c: Renamed ii.c. - * maps/iiss2.c: Renamed iiss.c. - * maps/is2.c: Renamed is.c. - * maps/issii2.c: Renamed issii.c. - * maps/isx2.c: Renamed isx.c. - * maps/map_format2.c: Renamed map_format.c. - * maps/si2.c: Renamed si.c. - * maps/keys.c: Deleted - * maps/test_list_int64.c: Deleted. - * maps/test_list_string.c: Deleted. - * maps/sort.c: Update to use new map API. - -2005-11-08 Martin Hunt <hunt@redhat.com> - - * pmaps/*: Add new pmaps tests. - -2005-10-28 Martin Hunt <hunt@redhat.com> - * maps/keys.c: New file. Tests specific to _stp_key_get_*(). - - * maps/iiss2.c (main): Add some comments to make clear expected - results. - * maps/is2.c (main): _stp_map_get_*s() now returns "" instead - of NULL when lookup fails. _stp_map_set_*s() now deletes a node - when setting to "" (as well as NULL). - * maps/setadd.c (main): Ditto. - * maps/map.test: update results. - -2005-10-26 Martin Hunt <hunt@redhat.com> - - * maps/map.test: Add results for iiiiii and ssssss. - * maps/iiiiii.c: New file. - * maps/ssssss.c: New file. - -2005-10-26 Martin Hunt <hunt@redhat.com> - - * maps/map.test: Add results for issii2. - -2005-10-26 Martin Hunt <hunt@redhat.com> - - * maps/map.test: Update with results for new tests. - * maps/*2.c: Tests for the new API. - * maps/ist.c: Renamed isx.c. - * maps/setadd.c: New test of adding and setting. - -2005-09-23 Martin Hunt <hunt@redhat.com> - - * maps/map.test: Add sort results. - * maps/sort.c: New test. - -2005-09-14 Martin Hunt <hunt@redhat.com> - - * maps/ii.c (main): Add test for _stp_map_clear(). - * maps/map.test: Update results. - -2005-09-12 Martin Hunt <hunt@redhat.com> - - * math/div64.c (main): Set the expected result for LLONG_MIN/-1 to - be LLONG_MIN (overflow) instead of 0. - -2005-09-09 Martin Hunt <hunt@redhat.com> - - * math/div64.c (main): Fixes for running on 64-bit hardware. - - * README: Update. - * math/div64.c: New file. 64-bit division tests. - diff --git a/runtime/tests/Makefile b/runtime/tests/Makefile deleted file mode 100644 index 4e744d25..00000000 --- a/runtime/tests/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -tests: - tclsh all.tcl - diff --git a/runtime/tests/README b/runtime/tests/README deleted file mode 100644 index 000f1017..00000000 --- a/runtime/tests/README +++ /dev/null @@ -1,7 +0,0 @@ -This directory contains the user-levels tests. - -Before running these for the first time, -> cd ../user -> ./recreate_links - -To run the test here, just type "make". diff --git a/runtime/tests/agg/Makefile b/runtime/tests/agg/Makefile deleted file mode 100644 index c396c132..00000000 --- a/runtime/tests/agg/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -default: tests - -tests: - tclsh all.tcl - diff --git a/runtime/tests/agg/agg.test b/runtime/tests/agg/agg.test deleted file mode 100644 index 2d56f031..00000000 --- a/runtime/tests/agg/agg.test +++ /dev/null @@ -1,169 +0,0 @@ -package require tcltest -namespace import -force tcltest::* - -cd $tcltest::testsDirectory - -set CFLAGS "-Os" -set KPATH "/lib/modules/[exec uname -r]/build/include" -set MPATH "/lib/modules/[exec uname -r]/build/include/asm/mach-default" -set PATH "../../user" - -test Counter {Counter Test} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test count.c -} -body { - exec ./test -} -result {cnt1[0] = 1 -cnt2[0] = 10 -cnt1[1] = 2 -cnt2[1] = 11 -cnt1[2] = 3 -cnt2[2] = 12 -cnt1[3] = 4 -cnt2[3] = 13 -cnt1[4] = 5 -cnt2[4] = 14 -cnt1[5] = 6 -cnt2[5] = 15 -cnt1[6] = 7 -cnt2[6] = 16 -cnt1[7] = 8 -cnt2[7] = 17 -cnt1 = 36 -cnt2 = 108 --------------------- -cnt1[0] = 2 -cnt2[0] = 20 -cnt1[1] = 4 -cnt2[1] = 22 -cnt1[2] = 6 -cnt2[2] = 24 -cnt1[3] = 8 -cnt2[3] = 26 -cnt1[4] = 10 -cnt2[4] = 28 -cnt1[5] = 12 -cnt2[5] = 30 -cnt1[6] = 14 -cnt2[6] = 32 -cnt1[7] = 16 -cnt2[7] = 34 -cnt1 = 72 -cnt2 = 216 --------------------- -cnt1 = 140 -cnt2 = 784 -cnt1 = 0 -cnt2 = 0 --------------------- -cnt1[0] = 0 -cnt2[0] = 0 -cnt1[1] = 1 -cnt2[1] = 1 -cnt1[2] = 4 -cnt2[2] = 8 -cnt1[3] = 9 -cnt2[3] = 27 -cnt1[4] = 16 -cnt2[4] = 64 -cnt1[5] = 25 -cnt2[5] = 125 -cnt1[6] = 36 -cnt2[6] = 216 -cnt1[7] = 49 -cnt2[7] = 343 -cnt1 = 140 -cnt2 = 784} - -test Stats {Stats Test} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test stats.c -} -body { - exec ./test -} -result {st1[0] = count: 1 sum:1 -st2[0] = count: 1 sum:10 -st3[0] = count: 1 sum:100 -st1[1] = count: 1 sum:2 -st2[1] = count: 1 sum:11 -st3[1] = count: 1 sum:101 -st1[2] = count: 1 sum:3 -st2[2] = count: 1 sum:12 -st3[2] = count: 1 sum:102 -st1[3] = count: 1 sum:4 -st2[3] = count: 1 sum:13 -st3[3] = count: 1 sum:103 -st1[4] = count: 1 sum:5 -st2[4] = count: 1 sum:14 -st3[4] = count: 1 sum:104 -st1[5] = count: 1 sum:6 -st2[5] = count: 1 sum:15 -st3[5] = count: 1 sum:105 -st1[6] = count: 1 sum:7 -st2[6] = count: 1 sum:16 -st3[6] = count: 1 sum:106 -st1[7] = count: 1 sum:8 -st2[7] = count: 1 sum:17 -st3[7] = count: 1 sum:107 --------------------- -CPU: 0 Count: 1 Sum: 1 -CPU: 1 Count: 1 Sum: 2 -CPU: 2 Count: 1 Sum: 3 -CPU: 3 Count: 1 Sum: 4 -CPU: 4 Count: 1 Sum: 5 -CPU: 5 Count: 1 Sum: 6 -CPU: 6 Count: 1 Sum: 7 -CPU: 7 Count: 1 Sum: 8 -CPU: 0 Count: 1 Sum: 10 -CPU: 1 Count: 1 Sum: 11 -CPU: 2 Count: 1 Sum: 12 -CPU: 3 Count: 1 Sum: 13 -CPU: 4 Count: 1 Sum: 14 -CPU: 5 Count: 1 Sum: 15 -CPU: 6 Count: 1 Sum: 16 -CPU: 7 Count: 1 Sum: 17 -CPU: 0 Count: 1 Sum: 100 -CPU: 1 Count: 1 Sum: 101 -CPU: 2 Count: 1 Sum: 102 -CPU: 3 Count: 1 Sum: 103 -CPU: 4 Count: 1 Sum: 104 -CPU: 5 Count: 1 Sum: 105 -CPU: 6 Count: 1 Sum: 106 -CPU: 7 Count: 1 Sum: 107 --------------------- -Count: 8 Sum: 36 -Count: 8 Sum: 108 -Count: 8 Sum: 828 --------------------- -count:8 sum:36 avg:4 min:1 max:8 - -count:8 sum:108 avg:13 min:10 max:17 -value |-------------------------------------------------- count - 2 | 0 - 4 | 0 - 8 |@@@@@@ 6 - 16 |@@ 2 - 32 | 0 - -count:8 sum:828 avg:103 min:100 max:107 -value |-------------------------------------------------- count - 85 | 0 - 90 | 0 - 95 |@@@@@@@@ 8 - -count:0 sum:0 avg:0 min:0 max:0 - -count:0 sum:0 avg:0 min:0 max:0 -value |-------------------------------------------------- count - 0 | 0 - 1 | 0 - 2 | 0 - -count:0 sum:0 avg:0 min:0 max:0 -value |-------------------------------------------------- count - 0 | 0 - 5 | 0 - 10 | 0 -} - - -exec rm test - -cleanupTests diff --git a/runtime/tests/agg/all.tcl b/runtime/tests/agg/all.tcl deleted file mode 100644 index 23757202..00000000 --- a/runtime/tests/agg/all.tcl +++ /dev/null @@ -1,4 +0,0 @@ -package require tcltest -namespace import -force tcltest::* -tcltest::testsDirectory [file dir [info script]] -tcltest::runAllTests diff --git a/runtime/tests/agg/count.c b/runtime/tests/agg/count.c deleted file mode 100644 index 8e674d1e..00000000 --- a/runtime/tests/agg/count.c +++ /dev/null @@ -1,72 +0,0 @@ -#include "runtime.h" - -/* test of Counters */ -#include "counter.c" - -int main () -{ - int i; - Counter cnt1 = _stp_counter_init(); - Counter cnt2 = _stp_counter_init(); - - /* testing _stp_counter_add(). These will only be correct if _stp_counter_init() */ - /* set all values to 0 and add works properly. */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - _stp_counter_add (cnt1, _processor_number + 1); - _stp_counter_add (cnt2, _processor_number + 10); - } - - /* testing _stp_counter_get_cpu() */ - for (i = 0; i < NR_CPUS; i++) { - printf ("cnt1[%d] = %lld\n", i, _stp_counter_get_cpu(cnt1, i, 0)); - printf ("cnt2[%d] = %lld\n", i, _stp_counter_get_cpu(cnt2, i, 0)); - } - - /* testing _stp_counter_get() */ - printf ("cnt1 = %d\n", _stp_counter_get(cnt1, 0)); - printf ("cnt2 = %d\n", _stp_counter_get(cnt2, 0)); - printf ("--------------------\n"); - - /* testing _stp_counter_add() */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - _stp_counter_add (cnt1, _processor_number + 1); - _stp_counter_add (cnt2, _processor_number + 10); - } - - for (i = 0; i < NR_CPUS; i++) { - printf ("cnt1[%d] = %lld\n", i, _stp_counter_get_cpu(cnt1, i, 0)); - printf ("cnt2[%d] = %lld\n", i, _stp_counter_get_cpu(cnt2, i, 0)); - } - printf ("cnt1 = %d\n", _stp_counter_get(cnt1, 1)); - printf ("cnt2 = %d\n", _stp_counter_get(cnt2, 1)); - - printf ("--------------------\n"); - - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - _stp_counter_add (cnt1, _processor_number * _processor_number); - _stp_counter_add (cnt2, _processor_number * _processor_number * _processor_number); - } - - printf ("cnt1 = %d\n", _stp_counter_get(cnt1, 1)); - printf ("cnt2 = %d\n", _stp_counter_get(cnt2, 1)); - printf ("cnt1 = %d\n", _stp_counter_get(cnt1, 0)); - printf ("cnt2 = %d\n", _stp_counter_get(cnt2, 0)); - printf ("--------------------\n"); - - - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - _stp_counter_add (cnt1, _processor_number * _processor_number); - _stp_counter_add (cnt2, _processor_number * _processor_number * _processor_number); - } - - for (i = 0; i < NR_CPUS; i++) { - printf ("cnt1[%d] = %lld\n", i, _stp_counter_get_cpu(cnt1, i, 0)); - printf ("cnt2[%d] = %lld\n", i, _stp_counter_get_cpu(cnt2, i, 0)); - } - printf ("cnt1 = %d\n", _stp_counter_get(cnt1, 0)); - printf ("cnt2 = %d\n", _stp_counter_get(cnt2, 0)); - - _stp_counter_free (cnt1); - _stp_counter_free (cnt2); - return 0; -} diff --git a/runtime/tests/agg/stats.c b/runtime/tests/agg/stats.c deleted file mode 100644 index 58fb9d41..00000000 --- a/runtime/tests/agg/stats.c +++ /dev/null @@ -1,62 +0,0 @@ -#include "runtime.h" - -/* test of Stats */ -#include "stat.c" - -int main () -{ - int i; - struct stat_data *st; - Stat st1 = _stp_stat_init(HIST_NONE); - Stat st2 = _stp_stat_init(HIST_LOG, 7); - Stat st3 = _stp_stat_init(HIST_LINEAR, 0, 100, 5); - - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - _stp_stat_add (st1, _processor_number + 1); - _stp_stat_add (st2, _processor_number + 10); - _stp_stat_add (st3, _processor_number + 100); - } - _processor_number = 0; - - /* this is for internal testing only. Not recommended */ - for (i = 0; i < NR_CPUS; i++) { - st = _stp_stat_get_cpu(st1, i); - printf ("st1[%d] = count: %lld sum:%lld\n", i, st->count, st->sum); - STAT_UNLOCK(st1); - st = _stp_stat_get_cpu(st2, i); - printf ("st2[%d] = count: %lld sum:%lld\n", i, st->count, st->sum); - STAT_UNLOCK(st2); - st = _stp_stat_get_cpu(st3, i); - printf ("st3[%d] = count: %lld sum:%lld\n", i, st->count, st->sum); - STAT_UNLOCK(st3); - } - _stp_printf ("--------------------\n"); - - /* normal way to print per-cpu stats */ - _stp_stat_print_cpu (st1, "CPU: %c\tCount: %C\tSum: %S", 0); - _stp_stat_print_cpu (st2, "CPU: %c\tCount: %C\tSum: %S", 0); - _stp_stat_print_cpu (st3, "CPU: %c\tCount: %C\tSum: %S", 0); - printf ("--------------------\n"); - - /* basic aggregated stats */ - _stp_stat_print (st1, "Count: %C\tSum: %S", 0); - _stp_stat_print (st2, "Count: %C\tSum: %S", 0); - _stp_stat_print (st3, "Count: %C\tSum: %S", 0); - printf ("--------------------\n"); - - /* now print full stats */ - _stp_stat_print (st1, "count:%C sum:%S avg:%A min:%m max:%M\n%H", 1); - _stp_stat_print (st2, "count:%C sum:%S avg:%A min:%m max:%M\n%H", 1); - _stp_stat_print (st3, "count:%C sum:%S avg:%A min:%m max:%M\n%H", 1); - - /* and print again, after they were cleared */ - _stp_stat_print (st1, "count:%C sum:%S avg:%A min:%m max:%M\n%H", 1); - _stp_stat_print (st2, "count:%C sum:%S avg:%A min:%m max:%M\n%H", 1); - _stp_stat_print (st3, "count:%C sum:%S avg:%A min:%m max:%M\n%H", 1); - - _stp_print_flush(); - _stp_stat_del(st1); - _stp_stat_del(st2); - _stp_stat_del(st3); - return 0; -} diff --git a/runtime/tests/all.tcl b/runtime/tests/all.tcl deleted file mode 100644 index f820c588..00000000 --- a/runtime/tests/all.tcl +++ /dev/null @@ -1,12 +0,0 @@ -package require tcltest -namespace import -force tcltest::* - -puts "Running all SystemTap tests" - -#puts [tcltest::configure] -#puts [tcltest::configure -file] - - -tcltest::runAllTests - -puts "All tests completed" diff --git a/runtime/tests/maps/Makefile b/runtime/tests/maps/Makefile deleted file mode 100644 index c396c132..00000000 --- a/runtime/tests/maps/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -default: tests - -tests: - tclsh all.tcl - diff --git a/runtime/tests/maps/README b/runtime/tests/maps/README deleted file mode 100644 index 3ff31703..00000000 --- a/runtime/tests/maps/README +++ /dev/null @@ -1,4 +0,0 @@ -Read ../README first! - -The *.c files test associative arrays (maps). "make tests" to run. - diff --git a/runtime/tests/maps/all.tcl b/runtime/tests/maps/all.tcl deleted file mode 100644 index c0b38a0e..00000000 --- a/runtime/tests/maps/all.tcl +++ /dev/null @@ -1,5 +0,0 @@ -package require tcltest -namespace import -force tcltest::* -tcltest::testsDirectory [file dir [info script]] -tcltest::runAllTests - diff --git a/runtime/tests/maps/ii.c b/runtime/tests/maps/ii.c deleted file mode 100644 index 51b0d766..00000000 --- a/runtime/tests/maps/ii.c +++ /dev/null @@ -1,96 +0,0 @@ -#include "runtime.h" - -/* test of maps with keys of int64 and value of int64 */ -#define VALUE_TYPE INT64 -#define KEY1_TYPE INT64 -#include "map-gen.c" - -#include "map.c" - -int main () -{ - MAP map = _stp_map_new_ii(4); - int64_t x; - - dbug("Hello World\n"); - - /* map[1] = 2 */ - _stp_map_set_ii(map, 1, 2); - x = _stp_map_get_ii(map, 1); - printf ("map[1]=%lld\n", x); - - /* map[3] = 4 */ - _stp_map_set_ii(map, 3, 4); - _stp_map_print(map,"map[%1d] = %d"); - - /* now try to confuse things */ - /* These won't do anything useful, but shouldn't crash */ - _stp_map_set_ii(0,1,100); - _stp_map_set_ii(map,0,0); - _stp_map_set_ii(map,100,0); - _stp_map_print(map,"map[%1d] = %d"); - - /* check that unset values are 0 */ - printf ("%lld (should be 0)\n", _stp_map_get_ii(map, 5)); - - /* map[5] = 6 */ - _stp_map_set_ii(map, 5, 6); - _stp_map_print(map,"map[%1d] = %d"); - - /* set wrap */ - map->wrap = 1; - /* add 4 new entries, pushing the others out */ - int i, res; - for (i = 6; i < 10; i++) { - res = _stp_map_set_ii (map, i, 100 + i); - if (res) - printf("WARNING: During wrap test, got result of %d when expected 0\n", res); - } - _stp_map_print(map,"map[%1d] = %d"); - - /* turn off wrap and repeat */ - map->wrap = 0; - for (i = 16; i < 20; i++) { - res = _stp_map_set_ii (map, i, 100 + i); - if (res != -1) - printf("WARNING: During wrap test, got result of %d when expected -1\n", res); - } - - map->wrap = 1; - - /* 5, 382, 526, and 903 all hash to the same value (23) */ - /* use them to test the hash chain */ - _stp_map_set_ii (map, 5, 1005); - _stp_map_set_ii (map, 382, 1382); - _stp_map_set_ii (map, 526, 1526); - _stp_map_set_ii (map, 903, 1903); - _stp_map_print(map,"map[%1d] = %d"); - - - /* now delete all 4 nodes, one by one */ - _stp_map_set_ii (map, 382, 0); - _stp_map_print(map,"map[%1d] = %d"); - - _stp_map_set_ii (map, 5, 0); - _stp_map_print(map,"map[%1d] = %d"); - - _stp_map_set_ii (map, 903, 0); - _stp_map_print(map,"map[%1d] = %d"); - - _stp_map_set_ii (map, 526, 0); - _stp_map_print(map,"map[%1d] = %d"); - - /* finally check clearing the map */ - for (i = 33; i < 77; i+=11) - _stp_map_set_ii (map, i, 100*i+i); - - _stp_map_print(map,"map[%1d] = %d"); - - _stp_map_clear(map); - _stp_map_print(map,"map[%1d] = %d"); - _stp_map_set_ii (map, 1970, 1799); - _stp_map_print(map,"map[%1d] = %d"); - - _stp_map_del (map); - return 0; -} diff --git a/runtime/tests/maps/iiiiii.c b/runtime/tests/maps/iiiiii.c deleted file mode 100644 index a5eeef70..00000000 --- a/runtime/tests/maps/iiiiii.c +++ /dev/null @@ -1,36 +0,0 @@ -#include "runtime.h" - -/* test of maps with 5 keys of int64 and value of int64 */ -#define VALUE_TYPE INT64 -#define KEY1_TYPE INT64 -#define KEY2_TYPE INT64 -#define KEY3_TYPE INT64 -#define KEY4_TYPE INT64 -#define KEY5_TYPE INT64 -#include "map-gen.c" - -#include "map.c" - -int main () -{ - struct map_node *ptr; - MAP map = _stp_map_new_iiiiii(4); - - _stp_map_set_iiiiii (map,1,2,3,4,5, 10); - _stp_map_set_iiiiii (map,10,20,30,40,50, 100); - _stp_map_set_iiiiii (map,-1,-2,-3,-4,-5, -10); - _stp_map_set_iiiiii (map,100,200,300,400,500, 1000); - - foreach (map, ptr) - printf ("map[%lld, %lld, %lld, %lld, %lld] = %lld\n", - _stp_key_get_int64(ptr,1), - _stp_key_get_int64(ptr,2), - _stp_key_get_int64(ptr,3), - _stp_key_get_int64(ptr,4), - _stp_key_get_int64(ptr,5), - _stp_get_int64(ptr)); - - _stp_map_print(map,"%1d - %2d - %3d - %4d - %5d *** %d"); - _stp_map_del (map); - return 0; -} diff --git a/runtime/tests/maps/iiss.c b/runtime/tests/maps/iiss.c deleted file mode 100644 index 96369d56..00000000 --- a/runtime/tests/maps/iiss.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "runtime.h" - -/* test of maps with keys of int64,int64,string and value of string */ -#define VALUE_TYPE STRING -#define KEY1_TYPE INT64 -#define KEY2_TYPE INT64 -#define KEY3_TYPE STRING -#include "map-gen.c" - -#include "map.c" - -int main () -{ - MAP map = _stp_map_new_iiss(4); - map->wrap = 1; - - _stp_map_set_iiss (map, 1,2,"Ohio", "Columbus" ); - _stp_map_set_iiss (map, 3,4,"California", "Sacramento" ); - _stp_map_set_iiss (map, 5,6,"Washington", "Seattle" ); - _stp_map_set_iiss (map, 7,8,"Oregon", "Salem" ); - _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - - _stp_map_set_iiss (map, -9,-10,"Nevada", "Carson City" ); - _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - - _stp_map_set_iiss (map, 5,6,"Washington", "Olymp" ); - _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - - _stp_map_add_iiss (map, 5,6,"Washington", "is" ); - _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - - _stp_map_set_iiss (map, 5,6,"Washington", "Olympia" ); - _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - - /* delete */ - _stp_map_set_iiss (map, -9,-10,"Nevada", 0); - _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - - /* should add nothing */ - _stp_map_set_iiss(map, 0,0,"", ""); - _stp_map_print (map, "map[%1d, %2d, %3s] = %s"); - - _stp_map_del (map); - return 0; -} diff --git a/runtime/tests/maps/is.c b/runtime/tests/maps/is.c deleted file mode 100644 index 3008f702..00000000 --- a/runtime/tests/maps/is.c +++ /dev/null @@ -1,119 +0,0 @@ -#include "runtime.h" - -/* test of maps with keys of int64 and value of string */ -#define KEY1_TYPE INT64 -#define VALUE_TYPE STRING -#include "map-gen.c" - -#include "map.c" - -int main () -{ - MAP map = _stp_map_new_is(4); - map->wrap = 1; - - /* map[1] = one */ - _stp_map_set_is (map, 1, "one"); - - printf ("map[1]=%s\n", _stp_map_get_is(map,1)); - _stp_map_print(map,"map[%1d] = %s"); - - /* map[3] = "three" */ - _stp_map_set_is (map, 3, "three"); - _stp_map_print(map,"map[%1d] = %s"); - - /* now try to confuse things */ - /* These won't do anything useful, but shouldn't crash */ - _stp_map_set_is(0,1,"foobar"); - _stp_map_set_is(map,0,0); - _stp_map_set_is(map,100,0); - _stp_map_print(map,"map[%1d] = %s"); - - /* create and delete a key */ - _stp_map_set_is (map, 1024, "2048"); - _stp_map_set_is (map, 1024, 0); - _stp_map_print(map,"map[%1d] = %s"); - - /* create and delete a key again*/ - _stp_map_set_is (map, 1024, "2048"); - _stp_map_print(map,"map[%1d] = %s"); - _stp_map_set_is (map, 1024, 0); - _stp_map_print(map,"map[%1d] = %s"); - - - /* check that unset values are "" */ - if (*_stp_map_get_is(map, 5)) - printf("ERROR: unset key has nonempty value\n"); - - /* map[5] = "five" */ - _stp_map_set_is (map, 5, "five"); - _stp_map_print(map,"map[%1d] = %s"); - - /* test empty string (should delete)*/ - _stp_map_set_is (map, 5, ""); - _stp_map_print(map,"map[%1d] = %s"); - - - /* add 4 new entries, pushing the others out */ - int i; - for (i = 6; i < 10; i++) - { - char buf[32]; - sprintf(buf, "value of %d", i); - _stp_map_set_is (map, i, buf); - } - _stp_map_print(map,"map[%1d] = %s"); - - /* 5, 382, 526, and 903 all hash to the same value (23) */ - /* use them to test the hash chain */ - _stp_map_set_is (map, 5, "1005"); - _stp_map_set_is (map, 382, "1382"); - _stp_map_set_is (map, 526, "1526"); - _stp_map_set_is (map, 903, "1903"); - - _stp_map_print(map,"map[%1d] = %s"); - - /* now delete all 4 nodes, one by one */ - _stp_map_set_is (map, 382, 0); - _stp_map_print(map,"map[%1d] = %s"); - - _stp_map_set_is (map, 5, 0); - _stp_map_print(map,"map[%1d] = %s"); - - _stp_map_set_is (map, 903, 0); - _stp_map_print(map,"map[%1d] = %s"); - - _stp_map_set_is (map, 526, 0); - _stp_map_print(map,"map[%1d] = %s"); - - /* test overflow errors */ - map->wrap = 0; - for (i = 6; i < 10; i++) - { - char buf[32]; - sprintf(buf, "value of %d", i); - _stp_map_set_is (map, i, buf); - } - - for (i = 6; i < 10; i++) - { - char buf[32]; - int res; - sprintf(buf, "new value of %d", i); - res = _stp_map_set_is (map, i, buf); - if (res) - printf("WARNING: During wrap test, got result of %d when expected 0\n", res); - } - for (i = 16; i < 20; i++) - { - char buf[32]; - int res; - sprintf(buf, "BAD value of %d", i); - res = _stp_map_set_is (map, i, buf); - if (res != -1) - printf("WARNING: During wrap test, got result of %d when expected -1\n", res); - } - _stp_map_print(map,"map[%1d] = %s"); - _stp_map_del (map); - return 0; -} diff --git a/runtime/tests/maps/issii.c b/runtime/tests/maps/issii.c deleted file mode 100644 index 4861428a..00000000 --- a/runtime/tests/maps/issii.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "runtime.h" - -/* test of maps with keys of int64,string.string.int64 and value of int64 */ -#define VALUE_TYPE INT64 -#define KEY1_TYPE INT64 -#define KEY2_TYPE STRING -#define KEY3_TYPE STRING -#define KEY4_TYPE INT64 -#include "map-gen.c" - -#include "map.c" - -int main () -{ - struct map_node *ptr; - MAP map = _stp_map_new_issii(4); - - _stp_map_set_issii (map, 1, "Boston", "MA", 1970, 5224303 ); - _stp_map_set_issii (map, 2, "Boston", "MA", 2000, 6057826 ); - _stp_map_set_issii (map, 3, "Chicago", "IL", 2000, 8272768 ); - - foreach (map, ptr) - printf ("map[%lld, %s, %s, %lld] = %lld\n", - key1int(ptr), - key2str(ptr), - _stp_key_get_str(ptr,3), - _stp_key_get_int64(ptr,4), - _stp_get_int64(ptr)); - - - _stp_map_print(map,"%1d. The population of %2s, %3s in %4d was %d"); - _stp_map_del (map); - return 0; -} diff --git a/runtime/tests/maps/isx.c b/runtime/tests/maps/isx.c deleted file mode 100644 index 9003f522..00000000 --- a/runtime/tests/maps/isx.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "runtime.h" - -/* test of maps with keys of int64 and value of stat */ -#define VALUE_TYPE STAT -#define KEY1_TYPE INT64 -#include "map-gen.c" -#include "map.c" - -int main () -{ - int i, j; - MAP map = _stp_map_new_ix (4, HIST_LINEAR, 0, 100, 10 ); - MAP map2 = _stp_map_new_ix(4, HIST_LOG, 11); - - for (i = 0; i < 100; i++) - for (j = 0; j <= i*10 ; j++ ) - _stp_map_add_ix (map, 3, i); - - for (i = 0; i < 10; i++) - for (j = 0; j < 10 ; j++ ) - _stp_map_add_ix (map, 2, j * i ); - - for (i = 0; i < 100; i += 10) - for (j = 0; j < i/10 ; j++ ) - _stp_map_add_ix (map, 1, i); - - for (i = 0; i < 128; i++) - for (j = 0; j < 128 ; j++ ) - _stp_map_add_ix (map2, 1, i); - - for (i = 0; i < 1024; i++) - for (j = 0; j < 1024 ; j++ ) - _stp_map_add_ix (map2, 2, i); - - _stp_map_print (map, "map[%1d] = count:%C sum:%S avg:%A min:%m max:%M\n%H"); - _stp_map_print (map2, "map2[%1d] = count:%C sum:%S avg:%A min:%m max:%M\n%H"); - - _stp_map_del (map); - _stp_map_del (map2); - return 0; -} diff --git a/runtime/tests/maps/map.test b/runtime/tests/maps/map.test deleted file mode 100644 index 51feca41..00000000 --- a/runtime/tests/maps/map.test +++ /dev/null @@ -1,999 +0,0 @@ -package require tcltest -namespace import -force tcltest::* - -cd $tcltest::testsDirectory - -set CFLAGS "-Os" -set KPATH "/lib/modules/[exec uname -r]/build/include" -set MPATH "/lib/modules/[exec uname -r]/build/include/asm/mach-default" -set PATH "../../user" - -test isx {Test of int64 keys and stat values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test isx.c -} -body { - exec ./test -} -result {map[3] = count:49600 sum:3288450 avg:66 min:0 max:99 -value |-------------------------------------------------- count - 0 |@@ 460 - 10 |@@@@@@@ 1460 - 20 |@@@@@@@@@@@@ 2460 - 30 |@@@@@@@@@@@@@@@@@@ 3460 - 40 |@@@@@@@@@@@@@@@@@@@@@@@ 4460 - 50 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5460 - 60 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6460 - 70 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7460 - 80 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8460 - 90 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9460 - -map[2] = count:100 sum:2025 avg:20 min:0 max:81 -value |-------------------------------------------------- count - 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 42 - 10 |@@@@@@@@@@@@@@@@@ 17 - 20 |@@@@@@@@@@@@@ 13 - 30 |@@@@@@@@@ 9 - 40 |@@@@@@@@@ 9 - 50 |@@@@ 4 - 60 |@@@ 3 - 70 |@@ 2 - 80 |@ 1 - 90 | 0 - -map[1] = count:45 sum:2850 avg:63 min:10 max:90 -value |-------------------------------------------------- count - 0 | 0 - 10 |@ 1 - 20 |@@ 2 - 30 |@@@ 3 - 40 |@@@@ 4 - 50 |@@@@@ 5 - 60 |@@@@@@ 6 - 70 |@@@@@@@ 7 - 80 |@@@@@@@@ 8 - 90 |@@@@@@@@@ 9 - - -map2[1] = count:16384 sum:1040384 avg:63 min:0 max:127 -value |-------------------------------------------------- count - 0 | 128 - 1 | 128 - 2 |@ 256 - 4 |@@@ 512 - 8 |@@@@@@ 1024 - 16 |@@@@@@@@@@@@ 2048 - 32 |@@@@@@@@@@@@@@@@@@@@@@@@ 4096 - 64 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8192 - 128 | 0 - 256 | 0 - -map2[2] = count:1048576 sum:536346624 avg:511 min:0 max:1023 -value |-------------------------------------------------- count - 0 | 1024 - 1 | 1024 - 2 | 2048 - 4 | 4096 - 8 | 8192 - 16 |@ 16384 - 32 |@@@ 32768 - 64 |@@@@@@ 65536 - 128 |@@@@@@@@@@@@ 131072 - 256 |@@@@@@@@@@@@@@@@@@@@@@@@ 262144 - 512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 524288 - -} - - -test map_format {Torture test of map formatting} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test map_format.c -} -body { - exec ./test -} -result {Columbus -> mapiis 1 2 Ohio -Sacramento -> mapiis 3 4 California -Olympia -> mapiis 5 6 Washington -Salem -> mapiis 7 8 Oregon - -Columbus % Ohio -Sacramento % California -Olympia % Washington -Salem % Oregon - -Columbus -> mapiis -Sacramento -> mapiis -Olympia -> mapiis -Salem -> mapiis - -The capitol of Riga is Latvia and the nerd population is 212063400820736 -The capitol of Sofia is Bulgaria and the nerd population is -2400999087387945352 -The capitol of Valletta is Malta and the nerd population is 1 -The capitol of Nicosia is Cyprus and the nerd population is -1 - -The capitol of Riga is Latvia and the nerd population is c0dedbad0000 -The capitol of Sofia is Bulgaria and the nerd population is deadf00d12345678 -The capitol of Valletta is Malta and the nerd population is 1 -The capitol of Nicosia is Cyprus and the nerd population is ffffffffffffffff - -The capitol of Riga is Latvia and the nerd population is C0DEDBAD0000 -The capitol of Sofia is Bulgaria and the nerd population is DEADF00D12345678 -The capitol of Valletta is Malta and the nerd population is 1 -The capitol of Nicosia is Cyprus and the nerd population is FFFFFFFFFFFFFFFF - -Bogons per packet for Riga -count:49600 sum:3288450 avg:66 min:0 max:99 -value |-------------------------------------------------- count - 0 |@@ 460 - 10 |@@@@@@@ 1460 - 20 |@@@@@@@@@@@@ 2460 - 30 |@@@@@@@@@@@@@@@@@@ 3460 - 40 |@@@@@@@@@@@@@@@@@@@@@@@ 4460 - 50 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5460 - 60 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6460 - 70 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7460 - 80 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8460 - 90 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9460 - -Bogons per packet for Sofia -count:100 sum:2025 avg:20 min:0 max:81 -value |-------------------------------------------------- count - 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 42 - 10 |@@@@@@@@@@@@@@@@@ 17 - 20 |@@@@@@@@@@@@@ 13 - 30 |@@@@@@@@@ 9 - 40 |@@@@@@@@@ 9 - 50 |@@@@ 4 - 60 |@@@ 3 - 70 |@@ 2 - 80 |@ 1 - 90 | 0 - -Bogons per packet for Valletta -count:45 sum:2850 avg:63 min:10 max:90 -value |-------------------------------------------------- count - 0 | 0 - 10 |@ 1 - 20 |@@ 2 - 30 |@@@ 3 - 40 |@@@@ 4 - 50 |@@@@@ 5 - 60 |@@@@@@ 6 - 70 |@@@@@@@ 7 - 80 |@@@@@@@@ 8 - 90 |@@@@@@@@@ 9 - - -49600 was the count for Riga, Latvia -100 was the count for Sofia, Bulgaria -45 was the count for Valletta, Malta - -mapsst[ Riga, Latvia] = 322D82 -mapsst[ Sofia, Bulgaria] = 7E9 -mapsst[ Valletta, Malta] = B22} - -test map_issii {Test of int64,string,string,int64 keys and int64 values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test issii.c -} -body { - exec ./test -} -result {map[1, Boston, MA, 1970] = 5224303 -map[2, Boston, MA, 2000] = 6057826 -map[3, Chicago, IL, 2000] = 8272768 -1. The population of Boston, MA in 1970 was 5224303 -2. The population of Boston, MA in 2000 was 6057826 -3. The population of Chicago, IL in 2000 was 8272768 -} - -test map_sort {Test of sorting} -setup { - puts "gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test sort.c" - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test sort.c -} -body { - exec ./test -} -result {sorting from A-Z on value -Boston -> 5 5 Massachusetts -Carson City -> 7 8 Nevada -Columbus -> 1 2 Ohio -Des Moines -> 8 8 Iowa -Montpelier -> 2 2 Vermont -Olympia -> 5 6 Washington -Raleigh -> -1 9 North Carolina -Sacramento -> 3 4 California -Salem -> 7 8 Oregon -Santa Fe -> 1 4 New Mexico - - -sorting from Z-A on value -Santa Fe -> 1 4 New Mexico -Salem -> 7 8 Oregon -Sacramento -> 3 4 California -Raleigh -> -1 9 North Carolina -Olympia -> 5 6 Washington -Montpelier -> 2 2 Vermont -Des Moines -> 8 8 Iowa -Columbus -> 1 2 Ohio -Carson City -> 7 8 Nevada -Boston -> 5 5 Massachusetts - - -sorting from low to high on key 1 --1 9 North Carolina -> Raleigh -1 4 New Mexico -> Santa Fe -1 2 Ohio -> Columbus -2 2 Vermont -> Montpelier -3 4 California -> Sacramento -5 6 Washington -> Olympia -5 5 Massachusetts -> Boston -7 8 Oregon -> Salem -7 8 Nevada -> Carson City -8 8 Iowa -> Des Moines - - -sorting from high to low on key 1 -8 8 Iowa -> Des Moines -7 8 Oregon -> Salem -7 8 Nevada -> Carson City -5 6 Washington -> Olympia -5 5 Massachusetts -> Boston -3 4 California -> Sacramento -2 2 Vermont -> Montpelier -1 4 New Mexico -> Santa Fe -1 2 Ohio -> Columbus --1 9 North Carolina -> Raleigh - - -sorting from low to high on key 2 -2 2 Vermont -> Montpelier -1 2 Ohio -> Columbus -3 4 California -> Sacramento -1 4 New Mexico -> Santa Fe -5 5 Massachusetts -> Boston -5 6 Washington -> Olympia -8 8 Iowa -> Des Moines -7 8 Oregon -> Salem -7 8 Nevada -> Carson City --1 9 North Carolina -> Raleigh - - -sorting from high to low on key 2 --1 9 North Carolina -> Raleigh -8 8 Iowa -> Des Moines -7 8 Oregon -> Salem -7 8 Nevada -> Carson City -5 6 Washington -> Olympia -5 5 Massachusetts -> Boston -3 4 California -> Sacramento -1 4 New Mexico -> Santa Fe -2 2 Vermont -> Montpelier -1 2 Ohio -> Columbus - - -sorting from low to high on key 3 -California 3 4 -> Sacramento -Iowa 8 8 -> Des Moines -Massachusetts 5 5 -> Boston -Nevada 7 8 -> Carson City -New Mexico 1 4 -> Santa Fe -North Carolina -1 9 -> Raleigh -Ohio 1 2 -> Columbus -Oregon 7 8 -> Salem -Vermont 2 2 -> Montpelier -Washington 5 6 -> Olympia - - -sorting from high to low on key 3 -Washington 5 6 -> Olympia -Vermont 2 2 -> Montpelier -Oregon 7 8 -> Salem -Ohio 1 2 -> Columbus -North Carolina -1 9 -> Raleigh -New Mexico 1 4 -> Santa Fe -Nevada 7 8 -> Carson City -Massachusetts 5 5 -> Boston -Iowa 8 8 -> Des Moines -California 3 4 -> Sacramento - - -top 3 alphabetical by value -Boston -> 5 5 Massachusetts -Carson City -> 7 8 Nevada -Columbus -> 1 2 Ohio - - -bottom 2 alphabetical by value -Santa Fe -> 1 4 New Mexico -Salem -> 7 8 Oregon - - -top 5 sorted by key 1 -8 8 Iowa -> Des Moines -7 8 Oregon -> Salem -7 8 Nevada -> Carson City -5 6 Washington -> Olympia -5 5 Massachusetts -> Boston - - -bottom 5 sorted by key 1 --1 9 North Carolina -> Raleigh -1 4 New Mexico -> Santa Fe -1 2 Ohio -> Columbus -2 2 Vermont -> Montpelier -3 4 California -> Sacramento - -sorted by population from low to high -Nicosia is the capitol of Cyprus and the nerd population is -1 -Valletta is the capitol of Malta and the nerd population is 1 -Riga is the capitol of Latvia and the nerd population is 135786 -Sofia is the capitol of Bulgaria and the nerd population is 138740 - -sorted by population from high to low -Sofia is the capitol of Bulgaria and the nerd population is 138740 -Riga is the capitol of Latvia and the nerd population is 135786 -Valletta is the capitol of Malta and the nerd population is 1 -Nicosia is the capitol of Cyprus and the nerd population is -1 -} - -test ii {Test of int64 keys and int64 values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ii.c -} -body { - exec ./test -} -result {map[1]=2 -map[1] = 2 -map[3] = 4 - -map[1] = 2 -map[3] = 4 - -0 (should be 0) -map[1] = 2 -map[3] = 4 -map[5] = 6 - -map[6] = 106 -map[7] = 107 -map[8] = 108 -map[9] = 109 - -map[5] = 1005 -map[382] = 1382 -map[526] = 1526 -map[903] = 1903 - -map[5] = 1005 -map[526] = 1526 -map[903] = 1903 - -map[526] = 1526 -map[903] = 1903 - -map[526] = 1526 - - -map[33] = 3333 -map[44] = 4444 -map[55] = 5555 -map[66] = 6666 - - -map[1970] = 1799 -} - -test is {Test of int64 keys and string values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test is.c -} -body { - exec ./test -} -result {map[1]=one -map[1] = one - -map[1] = one -map[3] = three - -map[1] = one -map[3] = three - -map[1] = one -map[3] = three - -map[1] = one -map[3] = three -map[1024] = 2048 - -map[1] = one -map[3] = three - -map[1] = one -map[3] = three -map[5] = five - -map[1] = one -map[3] = three - -map[6] = value of 6 -map[7] = value of 7 -map[8] = value of 8 -map[9] = value of 9 - -map[5] = 1005 -map[382] = 1382 -map[526] = 1526 -map[903] = 1903 - -map[5] = 1005 -map[526] = 1526 -map[903] = 1903 - -map[526] = 1526 -map[903] = 1903 - -map[526] = 1526 - - -map[6] = new value of 6 -map[7] = new value of 7 -map[8] = new value of 8 -map[9] = new value of 9 -} - -test si {Test of string keys and int64 values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test si.c -} -body { - exec ./test -} -result {map[Ohio]=1 -map[Ohio] = 1 - -map[Ohio] = 1 -map[Washington] = 2 - -map[Ohio] = 1 -map[Washington] = 2 - -map[Ohio] = 1 -map[Washington] = 2 -map[1024] = 2048 - -map[Ohio] = 1 -map[Washington] = 2 - -map[Ohio] = 1 -map[Washington] = 2 -map[1024] = 2048 - -map[Ohio] = 1 -map[Washington] = 2 - -map[Ohio] = 1 -map[Washington] = 2 -map[California] = 3 - -map[Ohio] = 1 -map[Washington] = 2 -map[California] = 3 -map[] = 7777 - -map[Ohio] = 1 -map[Washington] = 2 -map[California] = 3 -map[] = 8888 - -map[Ohio] = 1 -map[Washington] = 2 -map[California] = 3 - -map[String 6] = 106 -map[String 7] = 107 -map[String 8] = 108 -map[String 9] = 109 - -map[String 6] = 106 -map[String 7] = 107 -map[String 8] = 108 -map[String 9] = 109 - -map[String 6] = 6106 -map[String 7] = 7107 -map[String 8] = 8108 -map[String 9] = 9109 - -map[String 6] = 6 -map[String 7] = 7 -map[String 8] = 8 -map[String 9] = 9 - -} - -test iiss {Test of int64,int64,string keys and string values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test iiss.c -} -body { - exec ./test -} -result {map[1, 2, Ohio] = Columbus -map[3, 4, California] = Sacramento -map[5, 6, Washington] = Seattle -map[7, 8, Oregon] = Salem - -map[3, 4, California] = Sacramento -map[5, 6, Washington] = Seattle -map[7, 8, Oregon] = Salem -map[-9, -10, Nevada] = Carson City - -map[3, 4, California] = Sacramento -map[5, 6, Washington] = Olymp -map[7, 8, Oregon] = Salem -map[-9, -10, Nevada] = Carson City - -map[3, 4, California] = Sacramento -map[5, 6, Washington] = Olympis -map[7, 8, Oregon] = Salem -map[-9, -10, Nevada] = Carson City - -map[3, 4, California] = Sacramento -map[5, 6, Washington] = Olympia -map[7, 8, Oregon] = Salem -map[-9, -10, Nevada] = Carson City - -map[3, 4, California] = Sacramento -map[5, 6, Washington] = Olympia -map[7, 8, Oregon] = Salem - -map[3, 4, California] = Sacramento -map[5, 6, Washington] = Olympia -map[7, 8, Oregon] = Salem -} - -test setadd {Test of setting and adding values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test setadd.c -} -body { - exec ./test -} -result {mapi[1] = 1 -mapi[2] = 4 -mapi[3] = 9 -mapi[4] = 16 - -maps[1] = value of 1 -maps[2] = value of 2 -maps[3] = value of 3 -maps[4] = value of 4 - -mapx[1] = count:1 sum:1 avg:1 min:1 max:1 -mapx[2] = count:1 sum:2 avg:2 min:2 max:2 -mapx[3] = count:1 sum:3 avg:3 min:3 max:3 -mapx[4] = count:1 sum:4 avg:4 min:4 max:4 - -mapi[1] = 2 -mapi[2] = 8 -mapi[3] = 18 -mapi[4] = 32 - -maps[1] = value of 1***** -maps[2] = value of 2***** -maps[3] = value of 3***** -maps[4] = value of 4***** - -mapx[1] = count:2 sum:3 avg:1 min:1 max:2 -mapx[2] = count:2 sum:6 avg:3 min:2 max:4 -mapx[3] = count:2 sum:9 avg:4 min:3 max:6 -mapx[4] = count:2 sum:12 avg:6 min:4 max:8 - -Adding 0 -mapi[1] = 2 -mapi[2] = 8 -mapi[3] = 18 -mapi[4] = 32 - -maps[1] = value of 1***** -maps[2] = value of 2***** -maps[3] = value of 3***** -maps[4] = value of 4***** - -maps[1] = value of 1***** -maps[2] = value of 2***** -maps[3] = value of 3***** -maps[4] = value of 4***** - -mapx[1] = count:3 sum:3 avg:1 min:0 max:2 -mapx[2] = count:3 sum:6 avg:2 min:0 max:4 -mapx[3] = count:3 sum:9 avg:3 min:0 max:6 -mapx[4] = count:3 sum:12 avg:4 min:0 max:8 - -Add 'X' to strings -maps[1] = value of 1*****X -maps[2] = value of 2*****X -maps[3] = value of 3*****X -maps[4] = value of 4*****X - -setting everything to 0 - - - - -Adding 0 - - - -mapx[1] = count:1 sum:0 avg:0 min:0 max:0 -mapx[2] = count:1 sum:0 avg:0 min:0 max:0 -mapx[3] = count:1 sum:0 avg:0 min:0 max:0 -mapx[4] = count:1 sum:0 avg:0 min:0 max:0 - -setting everything to -1 -mapi[1] = -1 -mapi[2] = -1 -mapi[3] = -1 -mapi[4] = -1 - -mapx[1] = count:1 sum:-1 avg:-1 min:-1 max:-1 -mapx[2] = count:1 sum:-1 avg:-1 min:-1 max:-1 -mapx[3] = count:1 sum:-1 avg:-1 min:-1 max:-1 -mapx[4] = count:1 sum:-1 avg:-1 min:-1 max:-1 - -adding -1 -mapi[1] = -2 -mapi[2] = -2 -mapi[3] = -2 -mapi[4] = -2 - -mapx[1] = count:2 sum:-2 avg:-1 min:-1 max:-1 -mapx[2] = count:2 sum:-2 avg:-1 min:-1 max:-1 -mapx[3] = count:2 sum:-2 avg:-1 min:-1 max:-1 -mapx[4] = count:2 sum:-2 avg:-1 min:-1 max:-1 -} - -test iiiiii {Test of 5 int keys and an int value} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test iiiiii.c -} -body { - exec ./test -} -result {map[1, 2, 3, 4, 5] = 10 -map[10, 20, 30, 40, 50] = 100 -map[-1, -2, -3, -4, -5] = -10 -map[100, 200, 300, 400, 500] = 1000 -1 - 2 - 3 - 4 - 5 *** 10 -10 - 20 - 30 - 40 - 50 *** 100 --1 - -2 - -3 - -4 - -5 *** -10 -100 - 200 - 300 - 400 - 500 *** 1000 -} - -test ssssss {Test of 5 string keys and a string value} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ssssss.c -} -body { - exec ./test -} -result {map[1ABC, 2ABC, 3ABC, 4ABC, 5ABC] = 666 -map[1QRS, 2QRS, 3QRS, 4QRS, 5QRS] = 777 -map[1abc, 2abc, 3abc, 4abc, 5abc] = 888 -map[1XYZ, 2XYZ, 3XYZ, 4XYZ, 5XYZ] = 999 -1ABC and 2ABC and 3ABC and 4ABC and 5ABC ---> 666 -1QRS and 2QRS and 3QRS and 4QRS and 5QRS ---> 777 -1abc and 2abc and 3abc and 4abc and 5abc ---> 888 -1XYZ and 2XYZ and 3XYZ and 4XYZ and 5XYZ ---> 999 -} - -test sort_stat {Test of sorting stats} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test sort_stat.c -} -body { - exec ./test -} -result {Bogons per packet for California -count:49600 sum:3288450 avg:66 min:0 max:99 -value |-------------------------------------------------- count - 0 |@@ 460 - 10 |@@@@@@@ 1460 - 20 |@@@@@@@@@@@@ 2460 - 30 |@@@@@@@@@@@@@@@@@@ 3460 - 40 |@@@@@@@@@@@@@@@@@@@@@@@ 4460 - 50 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5460 - 60 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6460 - 70 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7460 - 80 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8460 - 90 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9460 - -Bogons per packet for Washington -count:100 sum:2025 avg:20 min:0 max:81 -value |-------------------------------------------------- count - 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 42 - 10 |@@@@@@@@@@@@@@@@@ 17 - 20 |@@@@@@@@@@@@@ 13 - 30 |@@@@@@@@@ 9 - 40 |@@@@@@@@@ 9 - 50 |@@@@ 4 - 60 |@@@ 3 - 70 |@@ 2 - 80 |@ 1 - 90 | 0 - -Bogons per packet for Oregon -count:90 sum:5700 avg:63 min:10 max:90 -value |-------------------------------------------------- count - 0 | 0 - 10 |@@ 2 - 20 |@@@@ 4 - 30 |@@@@@@ 6 - 40 |@@@@@@@@ 8 - 50 |@@@@@@@@@@ 10 - 60 |@@@@@@@@@@@@ 12 - 70 |@@@@@@@@@@@@@@ 14 - 80 |@@@@@@@@@@@@@@@@ 16 - 90 |@@@@@@@@@@@@@@@@@@ 18 - -Bogons per packet for Nevada -count:45 sum:2970 avg:66 min:10 max:98 -value |-------------------------------------------------- count - 0 | 0 - 10 |@ 1 - 20 |@@ 2 - 30 |@@@ 3 - 40 |@@@@ 4 - 50 |@@@@@ 5 - 60 |@@@@@@ 6 - 70 |@@@@@@@ 7 - 80 |@@@@@@@@ 8 - 90 |@@@@@@@@@ 9 - -Bogons per packet for Ohio -count:20 sum:1000 avg:50 min:50 max:50 -value |-------------------------------------------------- count - 30 | 0 - 40 | 0 - 50 |@@@@@@@@@@@@@@@@@@@@ 20 - 60 | 0 - 70 | 0 - -Bogons per packet for North Carolina -count:45 sum:-4200 avg:-93 min:-620 max:100 -value |-------------------------------------------------- count - 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@ 26 - 10 |@ 1 - 20 |@@ 2 - 30 |@ 1 - 40 |@@ 2 - 50 |@ 1 - 60 |@ 1 - 70 |@ 1 - 80 |@ 1 - 90 |@@@@@@@@@ 9 - -Bogons per packet for New Mexico -count:450 sum:8475 avg:18 min:-39 max:50 -value |-------------------------------------------------- count - 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 145 - 10 |@@@@@@@@@@@@@@@@@@@ 59 - 20 |@@@@@@@@@@@@@@@@@@@@@@@ 69 - 30 |@@@@@@@@@@@@@@@@@@@@@@@@@@ 79 - 40 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 89 - 50 |@@@ 9 - 60 | 0 - 70 | 0 - - -SORTED BY COUNT -49600 California -450 New Mexico -100 Washington -90 Oregon -45 Nevada -45 North Carolina -20 Ohio - -SORTED BY COUNT (low to high) -20 Ohio -45 Nevada -45 North Carolina -90 Oregon -100 Washington -450 New Mexico -49600 California - -SORTED BY SUM -3288450 California -8475 New Mexico -5700 Oregon -2970 Nevada -2025 Washington -1000 Ohio --4200 North Carolina - -SORTED BY SUM (low to high) --4200 North Carolina -1000 Ohio -2025 Washington -2970 Nevada -5700 Oregon -8475 New Mexico -3288450 California - -SORTED BY MIN -50 Ohio -10 Nevada -10 Oregon -0 Washington -0 California --39 New Mexico --620 North Carolina - -SORTED BY MIN (low to high) --620 North Carolina --39 New Mexico -0 Washington -0 California -10 Nevada -10 Oregon -50 Ohio - -SORTED BY MAX -100 North Carolina -99 California -98 Nevada -90 Oregon -81 Washington -50 New Mexico -50 Ohio - -SORTED BY MAX (low to high) -50 New Mexico -50 Ohio -81 Washington -90 Oregon -98 Nevada -99 California -100 North Carolina - -SORTED BY AVG -66 Nevada -66 California -63 Oregon -50 Ohio -20 Washington -18 New Mexico --93 North Carolina - -SORTED BY AVG (low to high) --93 North Carolina -18 New Mexico -20 Washington -50 Ohio -63 Oregon -66 Nevada -66 California -} - -test sort2 {Test of sorting (odd number of elements)} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test sort2.c -} -body { - exec ./test -} -result {sorting from A-Z on value -Boston -> 5 5 Massachusetts -Carson City -> 7 8 Nevada -Columbus -> 1 2 Ohio -Des Moines -> 8 8 Iowa -Olympia -> 5 6 Washington -Raleigh -> -1 9 North Carolina -Sacramento -> 3 4 California -Salem -> 7 8 Oregon -Santa Fe -> 1 4 New Mexico - - -sorting from Z-A on value -Santa Fe -> 1 4 New Mexico -Salem -> 7 8 Oregon -Sacramento -> 3 4 California -Raleigh -> -1 9 North Carolina -Olympia -> 5 6 Washington -Des Moines -> 8 8 Iowa -Columbus -> 1 2 Ohio -Carson City -> 7 8 Nevada -Boston -> 5 5 Massachusetts - - -sorting from low to high on key 1 --1 9 North Carolina -> Raleigh -1 4 New Mexico -> Santa Fe -1 2 Ohio -> Columbus -3 4 California -> Sacramento -5 6 Washington -> Olympia -5 5 Massachusetts -> Boston -7 8 Oregon -> Salem -7 8 Nevada -> Carson City -8 8 Iowa -> Des Moines - - -sorting from high to low on key 1 -8 8 Iowa -> Des Moines -7 8 Oregon -> Salem -7 8 Nevada -> Carson City -5 6 Washington -> Olympia -5 5 Massachusetts -> Boston -3 4 California -> Sacramento -1 4 New Mexico -> Santa Fe -1 2 Ohio -> Columbus --1 9 North Carolina -> Raleigh - - -sorting from low to high on key 2 -1 2 Ohio -> Columbus -3 4 California -> Sacramento -1 4 New Mexico -> Santa Fe -5 5 Massachusetts -> Boston -5 6 Washington -> Olympia -8 8 Iowa -> Des Moines -7 8 Oregon -> Salem -7 8 Nevada -> Carson City --1 9 North Carolina -> Raleigh - - -sorting from high to low on key 2 --1 9 North Carolina -> Raleigh -8 8 Iowa -> Des Moines -7 8 Oregon -> Salem -7 8 Nevada -> Carson City -5 6 Washington -> Olympia -5 5 Massachusetts -> Boston -3 4 California -> Sacramento -1 4 New Mexico -> Santa Fe -1 2 Ohio -> Columbus - - -sorting from low to high on key 3 -California 3 4 -> Sacramento -Iowa 8 8 -> Des Moines -Massachusetts 5 5 -> Boston -Nevada 7 8 -> Carson City -New Mexico 1 4 -> Santa Fe -North Carolina -1 9 -> Raleigh -Ohio 1 2 -> Columbus -Oregon 7 8 -> Salem -Washington 5 6 -> Olympia - - -sorting from high to low on key 3 -Washington 5 6 -> Olympia -Oregon 7 8 -> Salem -Ohio 1 2 -> Columbus -North Carolina -1 9 -> Raleigh -New Mexico 1 4 -> Santa Fe -Nevada 7 8 -> Carson City -Massachusetts 5 5 -> Boston -Iowa 8 8 -> Des Moines -California 3 4 -> Sacramento - - -top 3 alphabetical by value -Boston -> 5 5 Massachusetts -Carson City -> 7 8 Nevada -Columbus -> 1 2 Ohio - - -bottom 2 alphabetical by value -Santa Fe -> 1 4 New Mexico -Salem -> 7 8 Oregon - - -top 5 sorted by key 1 -8 8 Iowa -> Des Moines -7 8 Oregon -> Salem -7 8 Nevada -> Carson City -5 6 Washington -> Olympia -5 5 Massachusetts -> Boston - - -bottom 5 sorted by key 1 --1 9 North Carolina -> Raleigh -1 4 New Mexico -> Santa Fe -1 2 Ohio -> Columbus -3 4 California -> Sacramento -5 6 Washington -> Olympia - -sorted by population from low to high -Nicosia is the capitol of Cyprus and the nerd population is -1 -Valletta is the capitol of Malta and the nerd population is 1 -Chisinau is the capitol of Moldova and the nerd population is 1024 -Riga is the capitol of Latvia and the nerd population is 135786 -Sofia is the capitol of Bulgaria and the nerd population is 138740 - -sorted by population from high to low -Sofia is the capitol of Bulgaria and the nerd population is 138740 -Riga is the capitol of Latvia and the nerd population is 135786 -Chisinau is the capitol of Moldova and the nerd population is 1024 -Valletta is the capitol of Malta and the nerd population is 1 -Nicosia is the capitol of Cyprus and the nerd population is -1 -} - - -test size {Test of _stp_map_size()} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test size.c -} -body { - exec ./test -} -result {} - -catch {exec rm test} - -cleanupTests diff --git a/runtime/tests/maps/map_format.c b/runtime/tests/maps/map_format.c deleted file mode 100644 index 184aa79a..00000000 --- a/runtime/tests/maps/map_format.c +++ /dev/null @@ -1,72 +0,0 @@ -#include "runtime.h" - -/* torture test of map formatting */ -#define VALUE_TYPE STRING -#define KEY1_TYPE INT64 -#define KEY2_TYPE INT64 -#define KEY3_TYPE STRING -#include "map-gen.c" - -#define VALUE_TYPE INT64 -#define KEY1_TYPE STRING -#define KEY2_TYPE STRING -#include "map-gen.c" - -#define VALUE_TYPE STAT -#define KEY1_TYPE STRING -#define KEY2_TYPE STRING -#include "map-gen.c" - -#include "map.c" - -int main () -{ - MAP mapiis = _stp_map_new_iiss(4); - _stp_map_set_iiss (mapiis, 1,2,"Ohio", "Columbus" ); - _stp_map_set_iiss (mapiis, 3,4,"California", "Sacramento" ); - _stp_map_set_iiss (mapiis, 5,6,"Washington", "Olympia" ); - _stp_map_set_iiss (mapiis, 7,8,"Oregon", "Salem" ); - _stp_map_print (mapiis, "%s -> mapiis %1d %2d %3s"); - - /* test printing of '%' */ - _stp_map_print (mapiis, "%s %% %3s"); - - /* very bad string. don't crash */ - _stp_map_print (mapiis, "%s -> mapiis %1s %2s %3d %4d"); - - MAP mapss = _stp_map_new_ssi(4); - _stp_map_set_ssi (mapss, "Riga", "Latvia", 0x0000c0dedbad0000LL); - _stp_map_set_ssi (mapss, "Sofia", "Bulgaria", 0xdeadf00d12345678LL); - _stp_map_set_ssi (mapss, "Valletta", "Malta", 1); - _stp_map_set_ssi (mapss, "Nicosia", "Cyprus", -1); - _stp_map_print (mapss, "The capitol of %1s is %2s and the nerd population is %d"); - _stp_map_print (mapss, "The capitol of %1s is %2s and the nerd population is %x"); - _stp_map_print (mapss, "The capitol of %1s is %2s and the nerd population is %X"); - - MAP mapsst = _stp_map_new_ssx (4, HIST_LINEAR, 0, 100, 10 ); - int i,j; - - for (i = 0; i < 100; i++) - for (j = 0; j <= i*10 ; j++ ) - _stp_map_add_ssx (mapsst, "Riga", "Latvia", i); - - for (i = 0; i < 10; i++) - for (j = 0; j < 10 ; j++ ) - _stp_map_add_ssx (mapsst, "Sofia", "Bulgaria", j * i ); - - for (i = 0; i < 100; i += 10) - for (j = 0; j < i/10 ; j++ ) - _stp_map_add_ssx (mapsst, "Valletta", "Malta", i); - - _stp_map_print (mapsst, "Bogons per packet for %1s\ncount:%C sum:%S avg:%A min:%m max:%M\n%H"); - - _stp_map_print (mapsst, "%C was the count for %1s, %2s"); - - /* here's how to print a map without using _stp_map_print(). */ - struct map_node *ptr; - foreach (mapsst, ptr) - _stp_printf ("mapsst[%09s,%09s] = %llX\n", key1str(ptr), key2str(ptr), _stp_get_stat(ptr)->sum); - _stp_print_flush(); - - return 0; -} diff --git a/runtime/tests/maps/setadd.c b/runtime/tests/maps/setadd.c deleted file mode 100644 index 8eedbaa9..00000000 --- a/runtime/tests/maps/setadd.c +++ /dev/null @@ -1,245 +0,0 @@ -#include "runtime.h" - -/* verify correct set and add behavior */ -#define VALUE_TYPE INT64 -#define KEY1_TYPE INT64 -#define STP_MAP_II -#include "map-gen.c" - -#define VALUE_TYPE STRING -#define KEY1_TYPE INT64 -#include "map-gen.c" - -#define VALUE_TYPE STAT -#define KEY1_TYPE INT64 -#include "map-gen.c" - -#include "map.c" - -int main () -{ - int i, res; - MAP mapi = _stp_map_new_ii(4); - MAP maps = _stp_map_new_is(4); - MAP mapx = _stp_map_new_ix(4, HIST_NONE); - - /* use add to set initial values */ - for (i = 1; i < 5; i++) - { - res = _stp_map_add_ii (mapi, i, i*i); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print(mapi,"mapi[%1d] = %d"); - - for (i = 1; i < 5; i++) - { - char buf[32]; - sprintf(buf, "value of %d", i); - res = _stp_map_add_is (maps, i, buf); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print(maps,"maps[%1d] = %s"); - - for (i = 1; i < 5; i++) - { - res = _stp_map_add_ix (mapx, i, i); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print (mapx, "mapx[%1d] = count:%C sum:%S avg:%A min:%m max:%M"); - - /*************** now add some values *******************/ - - for (i = 1; i < 5; i++) - { - res = _stp_map_add_ii (mapi, i, i*i); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print(mapi,"mapi[%1d] = %d"); - - for (i = 1; i < 5; i++) - { - res = _stp_map_add_is (maps, i, "*****"); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print(maps,"maps[%1d] = %s"); - - for (i = 1; i < 5; i++) - { - res = _stp_map_add_ix (mapx, i, i+i); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print (mapx, "mapx[%1d] = count:%C sum:%S avg:%A min:%m max:%M"); - - /*************** now add 0 *******************/ - printf ("Adding 0\n"); - for (i = 1; i < 5; i++) - { - res = _stp_map_add_ii (mapi, i, 0); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print(mapi,"mapi[%1d] = %d"); - - for (i = 1; i < 5; i++) - { - res = _stp_map_add_is (maps, i, ""); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print(maps,"maps[%1d] = %s"); - - /* adding NULL should be same as adding "" for string values */ - for (i = 1; i < 5; i++) - { - res = _stp_map_add_is (maps, i, 0); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print(maps,"maps[%1d] = %s"); - - for (i = 1; i < 5; i++) - { - res = _stp_map_add_ix (mapx, i, 0); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print (mapx, "mapx[%1d] = count:%C sum:%S avg:%A min:%m max:%M"); - - /*************** now add X to strings *******************/ - printf ("Add 'X' to strings\n"); - for (i = 1; i < 5; i++) - { - res = _stp_map_add_is (maps, i, "X"); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print(maps,"maps[%1d] = %s"); - - /*************** now set to 0 (clear) *******************/ - printf ("setting everything to 0\n"); - for (i = 1; i < 5; i++) - { - res = _stp_map_set_ii (mapi, i, 0); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print(mapi,"mapi[%1d] = %d"); - - for (i = 1; i < 5; i++) - { - res = _stp_map_set_is (maps, i, ""); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print(maps,"maps[%1d] = %s"); - - /* set it back to something */ - for (i = 1; i < 5; i++) - { - char buf[32]; - sprintf(buf, "%d", i); - res = _stp_map_set_is (maps, i, buf); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - - /* setting to NULL also deletes */ - for (i = 1; i < 5; i++) - { - res = _stp_map_set_is (maps, i, 0); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print(maps,"maps[%1d] = %s"); - - for (i = 1; i < 5; i++) - { - res = _stp_map_set_ix (mapx, i, 0); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print (mapx, "mapx[%1d] = count:%C sum:%S avg:%A min:%m max:%M"); - - /*************** now add 0 *******************/ - printf ("Adding 0\n"); - for (i = 1; i < 5; i++) - { - res = _stp_map_add_ii (mapi, i, 0); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print(mapi,"mapi[%1d] = %d"); - - for (i = 1; i < 5; i++) - { - res = _stp_map_add_is (maps, i, 0); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print(maps,"maps[%1d] = %s"); - - for (i = 1; i < 5; i++) - { - res = _stp_map_add_is (maps, i, ""); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print(maps,"maps[%1d] = %s"); - - for (i = 1; i < 5; i++) - { - res = _stp_map_add_ix (mapx, i, 0); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print (mapx, "mapx[%1d] = count:%C sum:%S avg:%A min:%m max:%M"); - - - /*************** now set to -1 *******************/ - printf ("setting everything to -1\n"); - for (i = 1; i < 5; i++) - { - res = _stp_map_set_ii (mapi, i, -1); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print(mapi,"mapi[%1d] = %d"); - - for (i = 1; i < 5; i++) - { - res = _stp_map_set_ix (mapx, i, -1); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print (mapx, "mapx[%1d] = count:%C sum:%S avg:%A min:%m max:%M"); - - /*************** now add -1 *******************/ - printf ("adding -1\n"); - for (i = 1; i < 5; i++) - { - res = _stp_map_add_ii (mapi, i, -1); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print(mapi,"mapi[%1d] = %d"); - - for (i = 1; i < 5; i++) - { - res = _stp_map_add_ix (mapx, i, -1); - if (res) - printf("ERROR: got result of %d when expected 0\n", res); - } - _stp_map_print (mapx, "mapx[%1d] = count:%C sum:%S avg:%A min:%m max:%M"); - - - _stp_map_del (mapi); - _stp_map_del (maps); - _stp_map_del (mapx); - return 0; -} diff --git a/runtime/tests/maps/si.c b/runtime/tests/maps/si.c deleted file mode 100644 index d9db65d7..00000000 --- a/runtime/tests/maps/si.c +++ /dev/null @@ -1,125 +0,0 @@ -#include "runtime.h" - -/* test of maps with keys of string and value of int64 */ -#define VALUE_TYPE INT64 -#define KEY1_TYPE STRING -#include "map-gen.c" -#include "map.c" - -int main () -{ - int res; - MAP map = _stp_map_new_si(4); - map->wrap = 1; - - /* map[Ohio] = 1 */ - _stp_map_set_si (map, "Ohio", 1); - printf ("map[Ohio]=%lld\n", _stp_map_get_si(map,"Ohio")); - _stp_map_print(map,"map[%1s] = %d"); - - /* map[Washington] = 2 */ - _stp_map_set_si (map, "Washington", 2); - _stp_map_print (map, "map[%1s] = %d"); - - /* now try to confuse things */ - /* These won't do anything useful, but shouldn't crash */ - - /* bad map */ - res = _stp_map_set_si(0,"foo",100); - if (res != -2) - printf("WARNING: got result of %d when expected -2\n", res); - - /* bad key */ - res = _stp_map_set_si(map,0,0); - if (res != -2) - printf("WARNING: got result of %d when expected -2\n", res); - - /* bad key */ - res = _stp_map_set_si(map,0,42); - if (res != -2) - printf("WARNING: got result of %d when expected -2\n", res); - - res = _stp_map_set_si(map,"",0); - if (res) - printf("WARNING: got result of %d when expected 0\n", res); - _stp_map_print (map, "map[%1s] = %d"); - - /* create and delete a key */ - _stp_map_set_si (map, "1024", 2048); - _stp_map_print (map, "map[%1s] = %d"); - _stp_map_set_si (map, "1024", 0); - _stp_map_print (map, "map[%1s] = %d"); - _stp_map_set_si (map, "1024", 2048); - _stp_map_print (map, "map[%1s] = %d"); - _stp_map_set_si (map, "1024", 0); - _stp_map_print (map, "map[%1s] = %d"); - - /* check that unset values are 0 */ - res = _stp_map_get_si (map, "California"); - if (res) - printf("ERROR: map[California] = %d (should be 0)\n", res); - - /* map[California] = 3 */ - _stp_map_set_si (map, "California", 3); - _stp_map_print (map, "map[%1s] = %d"); - - /* test an empty string as key */ - _stp_map_set_si (map, "", 7777); - _stp_map_print (map, "map[%1s] = %d"); - _stp_map_set_si (map, "", 8888); - _stp_map_print (map, "map[%1s] = %d"); - _stp_map_set_si (map, "", 0); - _stp_map_print (map, "map[%1s] = %d"); - - - /* add 4 new entries, pushing the others out */ - int i; - for (i = 6; i < 10; i++) - { - char buf[32]; - sprintf (buf, "String %d", i); - res = _stp_map_set_si (map, buf, 100 + i); - if (res) - printf("WARNING: During wrap test, got result of %d when expected 0\n", res); - } - _stp_map_print (map, "map[%1s] = %d"); - - /* turn off wrap and repeat */ - map->wrap = 0; - for (i = 16; i < 20; i++) { - char buf[32]; - sprintf (buf, "BAD String %d", i); - res = _stp_map_set_si (map, buf, 100 + i); - if (res != -1) - printf("WARNING: During wrap test, got result of %d when expected -1\n", res); - } - _stp_map_print (map, "map[%1s] = %d"); - - /* test addition */ - for (i = 6; i < 10; i++) - { - char buf[32]; - sprintf (buf, "String %d", i); - res = _stp_map_add_si (map, buf, 1000 * i); - if (res) - printf("WARNING: During wrap test, got result of %d when expected 0\n", res); - } - _stp_map_print (map, "map[%1s] = %d"); - - /* reset all */ - for (i = 6; i < 10; i++) - { - char buf[32]; - sprintf (buf, "String %d", i); - res = _stp_map_set_si (map, buf, i); - if (res) - printf("WARNING: During wrap test, got result of %d when expected 0\n", res); - } - _stp_map_print (map, "map[%1s] = %d"); - - _stp_map_clear(map); - _stp_map_print (map, "map[%1s] = %d"); - - _stp_map_del (map); - return 0; -} diff --git a/runtime/tests/maps/size.c b/runtime/tests/maps/size.c deleted file mode 100644 index 2fb2575c..00000000 --- a/runtime/tests/maps/size.c +++ /dev/null @@ -1,103 +0,0 @@ -#include "runtime.h" - -/* test of _stp_map_size() */ -#define VALUE_TYPE INT64 -#define KEY1_TYPE INT64 -#include "map-gen.c" - -#include "map.c" - -#define check(map,num) \ - { \ - int size = _stp_map_size(map); \ - if (size != num) \ - printf("ERROR at line %d: expected size %d and got %d instead.\n", __LINE__, num, size); \ - } - -int main () -{ - MAP map = _stp_map_new_ii(4); - int64_t x; - - check (map, 0); - - /* map[1] = 2 */ - _stp_map_set_ii(map, 1, 2); - check (map, 1); - - /* map[3] = 4 */ - _stp_map_set_ii(map, 3, 4); - check (map,2); - - /* now try to confuse things */ - /* These won't do anything useful, but shouldn't crash */ - _stp_map_set_ii(0,1,100); - _stp_map_set_ii(map,0,0); - _stp_map_set_ii(map,100,0); - check (map,2); - - /* map[5] = 6 */ - _stp_map_set_ii(map, 5, 6); - check (map,3); - - /* set wrap */ - map->wrap = 1; - /* add 4 new entries, pushing the others out */ - int i, res; - for (i = 6; i < 10; i++) { - res = _stp_map_set_ii (map, i, 100 + i); - if (res) - printf("WARNING: During wrap test, got result of %d when expected 0\n", res); - } - check (map,4); - - /* turn off wrap and repeat */ - map->wrap = 0; - for (i = 16; i < 20; i++) { - res = _stp_map_set_ii (map, i, 100 + i); - if (res != -1) - printf("WARNING: During wrap test, got result of %d when expected -1\n", res); - } - check (map,4); - - map->wrap = 1; - - /* 5, 382, 526, and 903 all hash to the same value (23) */ - /* use them to test the hash chain */ - _stp_map_set_ii (map, 5, 1005); - _stp_map_set_ii (map, 382, 1382); - _stp_map_set_ii (map, 526, 1526); - _stp_map_set_ii (map, 903, 1903); - check (map,4); - - /* now delete all 4 nodes, one by one */ - _stp_map_set_ii (map, 382, 0); - check (map,3); - - _stp_map_set_ii (map, 5, 0); - check (map,2); - - _stp_map_set_ii (map, 903, 0); - check (map,1); - - _stp_map_set_ii (map, 526, 0); - check (map,0); - - /* finally check clearing the map */ - _stp_map_clear(map); - check (map,0); - - map->wrap = 0; - for (i = 33; i < 99; i+=11) - _stp_map_set_ii (map, i, 100*i+i); - check (map,4); - - _stp_map_clear(map); - check (map,0); - - _stp_map_set_ii (map, 1970, 1799); - check (map,1); - - _stp_map_del (map); - return 0; -} diff --git a/runtime/tests/maps/sort.c b/runtime/tests/maps/sort.c deleted file mode 100644 index 7ae22206..00000000 --- a/runtime/tests/maps/sort.c +++ /dev/null @@ -1,105 +0,0 @@ -#include "runtime.h" - -/* test of map sorting */ -#define VALUE_TYPE STRING -#define KEY1_TYPE INT64 -#define KEY2_TYPE INT64 -#define KEY3_TYPE STRING -#include "map-gen.c" - -#define VALUE_TYPE INT64 -#define KEY1_TYPE STRING -#define KEY2_TYPE STRING -#include "map-gen.c" - -#include "map.c" - -int main () -{ - MAP mapiis = _stp_map_new_iiss(10); - - /* try to crash the sorts with sorting an empty list */ - _stp_map_sort (mapiis, 0, -1); - _stp_map_sort (mapiis, 0, 1); - _stp_map_sortn (mapiis, 3, 0, -1); - _stp_map_sortn (mapiis, 0, 0, -1); - - /* load some test data */ - _stp_map_add_iiss (mapiis, 3,4,"California","Sacramento" ); - _stp_map_set_iiss (mapiis, 5,6,"Washington","Olympia" ); - _stp_map_set_iiss (mapiis, 7,8,"Oregon","Salem" ); - _stp_map_set_iiss (mapiis, 7,8,"Nevada","Carson City" ); - _stp_map_set_iiss (mapiis, 1, 4,"New Mexico","Santa Fe" ); - _stp_map_set_iiss (mapiis, -1,9,"North Carolina","Raleigh" ); - _stp_map_set_iiss (mapiis, 5,5,"Massachusetts","Boston" ); - _stp_map_set_iiss (mapiis, 2,2,"Vermont","Montpelier" ); - _stp_map_set_iiss (mapiis, 8,8,"Iowa","Des Moines" ); - _stp_map_set_iiss (mapiis, 1,2,"Ohio","Columbus" ); - - _stp_printf("sorting from A-Z on value\n"); - _stp_map_sort (mapiis, 0, -1); - _stp_map_print (mapiis, "%s -> %1d %2d %3s"); - - _stp_printf("\nsorting from Z-A on value\n"); - _stp_map_sort (mapiis, 0, 1); - _stp_map_print (mapiis, "%s -> %1d %2d %3s"); - - _stp_printf("\nsorting from low to high on key 1\n"); - _stp_map_sort (mapiis, 1, -1); - _stp_map_print (mapiis, "%1d %2d %3s -> %s"); - - _stp_printf("\nsorting from high to low on key 1\n"); - _stp_map_sort (mapiis, 1, 1); - _stp_map_print (mapiis, "%1d %2d %3s -> %s"); - - _stp_printf("\nsorting from low to high on key 2\n"); - _stp_map_sort (mapiis, 2, -1); - _stp_map_print (mapiis, "%1d %2d %3s -> %s"); - - _stp_printf("\nsorting from high to low on key 2\n"); - _stp_map_sort (mapiis, 2, 1); - _stp_map_print (mapiis, "%1d %2d %3s -> %s"); - - - _stp_printf("\nsorting from low to high on key 3\n"); - _stp_map_sort (mapiis, 3, -1); - _stp_map_print (mapiis, "%3s\t\t%1d %2d -> %s"); - - _stp_printf("\nsorting from high to low on key 3\n"); - _stp_map_sort (mapiis, 3, 1); - _stp_map_print (mapiis, "%3s\t\t%1d %2d -> %s"); - - _stp_printf("\ntop 3 alphabetical by value\n"); - _stp_map_sortn (mapiis, 3, 0, -1); - _stp_map_printn (mapiis, 3, "%s -> %1d %2d %3s"); - - _stp_printf("\nbottom 2 alphabetical by value\n"); - _stp_map_sortn (mapiis, 2, 0, 1); - _stp_map_printn (mapiis, 2, "%s -> %1d %2d %3s"); - - - _stp_printf("\ntop 5 sorted by key 1\n"); - _stp_map_sortn (mapiis, 5, 1, 1); - _stp_map_printn (mapiis, 5, "%1d %2d %3s -> %s"); - _stp_printf("\nbottom 5 sorted by key 1\n"); - _stp_map_sortn (mapiis, 5, 1, -1); - _stp_map_printn (mapiis, 5, "%1d %2d %3s -> %s"); - - MAP mapss = _stp_map_new_ssi(4); - _stp_map_set_ssi (mapss, "Riga", "Latvia", 135786); - _stp_map_set_ssi (mapss, "Sofia", "Bulgaria", 138740); - _stp_map_set_ssi (mapss, "Valletta", "Malta", 1); - _stp_map_set_ssi (mapss, "Nicosia", "Cyprus", -1); - - _stp_printf("sorted by population from low to high\n"); - _stp_map_sort (mapss, 0, -1); - _stp_map_print (mapss, "%1s is the capitol of %2s and the nerd population is %d"); - _stp_printf("sorted by population from high to low\n"); - _stp_map_sort (mapss, 0, 1); - _stp_map_print (mapss, "%1s is the capitol of %2s and the nerd population is %d"); - - _stp_map_del(mapss); - _stp_map_del(mapiis); - - return 0; -} diff --git a/runtime/tests/maps/sort2.c b/runtime/tests/maps/sort2.c deleted file mode 100644 index 0b3bc547..00000000 --- a/runtime/tests/maps/sort2.c +++ /dev/null @@ -1,105 +0,0 @@ -#include "runtime.h" - -/* test of map sorting. Just like sort.c, except test with an odd number of nodes */ -#define VALUE_TYPE STRING -#define KEY1_TYPE INT64 -#define KEY2_TYPE INT64 -#define KEY3_TYPE STRING -#include "map-gen.c" - -#define VALUE_TYPE INT64 -#define KEY1_TYPE STRING -#define KEY2_TYPE STRING -#include "map-gen.c" - -#include "map.c" - -int main () -{ - MAP mapiis = _stp_map_new_iiss(10); - - /* try to crash the sorts with sorting an empty list */ - _stp_map_sort (mapiis, 0, -1); - _stp_map_sort (mapiis, 0, 1); - _stp_map_sortn (mapiis, 3, 0, -1); - _stp_map_sortn (mapiis, 0, 0, -1); - - /* load some test data */ - _stp_map_add_iiss (mapiis, 3,4,"California","Sacramento" ); - _stp_map_set_iiss (mapiis, 5,6,"Washington","Olympia" ); - _stp_map_set_iiss (mapiis, 7,8,"Oregon","Salem" ); - _stp_map_set_iiss (mapiis, 7,8,"Nevada","Carson City" ); - _stp_map_set_iiss (mapiis, 1, 4,"New Mexico","Santa Fe" ); - _stp_map_set_iiss (mapiis, -1,9,"North Carolina","Raleigh" ); - _stp_map_set_iiss (mapiis, 5,5,"Massachusetts","Boston" ); - _stp_map_set_iiss (mapiis, 8,8,"Iowa","Des Moines" ); - _stp_map_set_iiss (mapiis, 1,2,"Ohio","Columbus" ); - - _stp_printf("sorting from A-Z on value\n"); - _stp_map_sort (mapiis, 0, -1); - _stp_map_print (mapiis, "%s -> %1d %2d %3s"); - - _stp_printf("\nsorting from Z-A on value\n"); - _stp_map_sort (mapiis, 0, 1); - _stp_map_print (mapiis, "%s -> %1d %2d %3s"); - - _stp_printf("\nsorting from low to high on key 1\n"); - _stp_map_sort (mapiis, 1, -1); - _stp_map_print (mapiis, "%1d %2d %3s -> %s"); - - _stp_printf("\nsorting from high to low on key 1\n"); - _stp_map_sort (mapiis, 1, 1); - _stp_map_print (mapiis, "%1d %2d %3s -> %s"); - - _stp_printf("\nsorting from low to high on key 2\n"); - _stp_map_sort (mapiis, 2, -1); - _stp_map_print (mapiis, "%1d %2d %3s -> %s"); - - _stp_printf("\nsorting from high to low on key 2\n"); - _stp_map_sort (mapiis, 2, 1); - _stp_map_print (mapiis, "%1d %2d %3s -> %s"); - - - _stp_printf("\nsorting from low to high on key 3\n"); - _stp_map_sort (mapiis, 3, -1); - _stp_map_print (mapiis, "%3s\t\t%1d %2d -> %s"); - - _stp_printf("\nsorting from high to low on key 3\n"); - _stp_map_sort (mapiis, 3, 1); - _stp_map_print (mapiis, "%3s\t\t%1d %2d -> %s"); - - _stp_printf("\ntop 3 alphabetical by value\n"); - _stp_map_sortn (mapiis, 3, 0, -1); - _stp_map_printn (mapiis, 3, "%s -> %1d %2d %3s"); - - _stp_printf("\nbottom 2 alphabetical by value\n"); - _stp_map_sortn (mapiis, 2, 0, 1); - _stp_map_printn (mapiis, 2, "%s -> %1d %2d %3s"); - - - _stp_printf("\ntop 5 sorted by key 1\n"); - _stp_map_sortn (mapiis, 5, 1, 1); - _stp_map_printn (mapiis, 5, "%1d %2d %3s -> %s"); - _stp_printf("\nbottom 5 sorted by key 1\n"); - _stp_map_sortn (mapiis, 5, 1, -1); - _stp_map_printn (mapiis, 5, "%1d %2d %3s -> %s"); - - MAP mapss = _stp_map_new_ssi(5); - _stp_map_set_ssi (mapss, "Riga", "Latvia", 135786); - _stp_map_set_ssi (mapss, "Sofia", "Bulgaria", 138740); - _stp_map_set_ssi (mapss, "Valletta", "Malta", 1); - _stp_map_set_ssi (mapss, "Nicosia", "Cyprus", -1); - _stp_map_set_ssi (mapss, "Chisinau", "Moldova", 1024); - - _stp_printf("sorted by population from low to high\n"); - _stp_map_sort (mapss, 0, -1); - _stp_map_print (mapss, "%1s is the capitol of %2s and the nerd population is %d"); - _stp_printf("sorted by population from high to low\n"); - _stp_map_sort (mapss, 0, 1); - _stp_map_print (mapss, "%1s is the capitol of %2s and the nerd population is %d"); - - _stp_map_del(mapss); - _stp_map_del(mapiis); - - return 0; -} diff --git a/runtime/tests/maps/sort_stat.c b/runtime/tests/maps/sort_stat.c deleted file mode 100644 index f3f0435e..00000000 --- a/runtime/tests/maps/sort_stat.c +++ /dev/null @@ -1,90 +0,0 @@ -#include "runtime.h" - -/* test of map sorting */ - -#define VALUE_TYPE STAT -#define KEY1_TYPE STRING -#define KEY2_TYPE STRING -#include "map-gen.c" - -#include "map.c" - -int main () -{ - MAP mapssx = _stp_map_new_ssx (8, HIST_LINEAR, 0, 100, 10 ); - int i,j; - - for (i = 0; i < 100; i++) - for (j = 0; j <= i*10 ; j++ ) - _stp_map_add_ssx (mapssx, "California", "Sacramento", i); - - for (i = 0; i < 10; i++) - for (j = 0; j < 10 ; j++ ) - _stp_map_add_ssx (mapssx, "Washington", "Olympia", j * i ); - - for (i = 0; i < 100; i += 10) - for (j = 0; j < i/5 ; j++ ) - _stp_map_add_ssx (mapssx, "Oregon", "Salem", i); - - for (i = 0; i < 100; i += 10) - for (j = 0; j < i/10 ; j++ ) - _stp_map_add_ssx (mapssx, "Nevada", "Carson City", i + j); - - for (i = 0; i < 100; i += 10) - for (j = 0; j < i/20 ; j++ ) - _stp_map_add_ssx (mapssx, "Ohio", "Columbus", 50); - - for (i = 0; i < 100; i += 10) - for (j = 0; j < i/10 ; j++ ) - _stp_map_add_ssx (mapssx, "North Carolina", "Raleigh", 100 - j * i); - - for (i = 0; i < 100; i += 10) - for (j = 0; j < i ; j++ ) - _stp_map_add_ssx (mapssx, "New Mexico", "Santa Fe", 50 - j); - - - _stp_map_print (mapssx, "Bogons per packet for %1s\ncount:%C sum:%S avg:%A min:%m max:%M\n%H"); - - _stp_printf("SORTED BY COUNT\n"); - _stp_map_sort (mapssx, SORT_COUNT, 1); - _stp_map_print (mapssx, "%C %1s"); - - _stp_printf("SORTED BY COUNT (low to high)\n"); - _stp_map_sort (mapssx, SORT_COUNT, -1); - _stp_map_print (mapssx, "%C %1s"); - - _stp_printf("SORTED BY SUM\n"); - _stp_map_sort (mapssx, SORT_SUM, 1); - _stp_map_print (mapssx, "%S %1s"); - - _stp_printf("SORTED BY SUM (low to high)\n"); - _stp_map_sort (mapssx, SORT_SUM, -1); - _stp_map_print (mapssx, "%S %1s"); - - _stp_printf("SORTED BY MIN\n"); - _stp_map_sort (mapssx, SORT_MIN, 1); - _stp_map_print (mapssx, "%m %1s"); - - _stp_printf("SORTED BY MIN (low to high)\n"); - _stp_map_sort (mapssx, SORT_MIN, -1); - _stp_map_print (mapssx, "%m %1s"); - - _stp_printf("SORTED BY MAX\n"); - _stp_map_sort (mapssx, SORT_MAX, 1); - _stp_map_print (mapssx, "%M %1s"); - - _stp_printf("SORTED BY MAX (low to high)\n"); - _stp_map_sort (mapssx, SORT_MAX, -1); - _stp_map_print (mapssx, "%M %1s"); - - _stp_printf("SORTED BY AVG\n"); - _stp_map_sort (mapssx, SORT_AVG, 1); - _stp_map_print (mapssx, "%A %1s"); - - _stp_printf("SORTED BY AVG (low to high)\n"); - _stp_map_sort (mapssx, SORT_AVG, -1); - _stp_map_print (mapssx, "%A %1s"); - - _stp_map_del (mapssx); - return 0; -} diff --git a/runtime/tests/maps/ssssss.c b/runtime/tests/maps/ssssss.c deleted file mode 100644 index 1cc020b7..00000000 --- a/runtime/tests/maps/ssssss.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "runtime.h" - -/* test of maps with keys 5 strings and values of string */ -#define VALUE_TYPE STRING -#define KEY1_TYPE STRING -#define KEY2_TYPE STRING -#define KEY3_TYPE STRING -#define KEY4_TYPE STRING -#define KEY5_TYPE STRING -#include "map-gen.c" - -#include "map.c" - -int main () -{ - struct map_node *ptr; - MAP map = _stp_map_new_ssssss(4); - - _stp_map_set_ssssss (map, "1ABC", "2ABC", "3ABC", "4ABC", "5ABC", "666"); - _stp_map_set_ssssss (map, "1QRS", "2QRS", "3QRS", "4QRS", "5QRS", "777"); - _stp_map_set_ssssss (map, "1abc", "2abc", "3abc", "4abc", "5abc", "888"); - _stp_map_set_ssssss (map, "1XYZ", "2XYZ", "3XYZ", "4XYZ", "5XYZ", "999"); - - foreach (map, ptr) - printf ("map[%s, %s, %s, %s, %s] = %s\n", - _stp_key_get_str(ptr,1), - _stp_key_get_str(ptr,2), - _stp_key_get_str(ptr,3), - _stp_key_get_str(ptr,4), - _stp_key_get_str(ptr,5), - _stp_get_str(ptr)); - - - _stp_map_print(map,"%1s and %2s and %3s and %4s and %5s ---> %s"); - _stp_map_del (map); - return 0; -} diff --git a/runtime/tests/math/Makefile b/runtime/tests/math/Makefile deleted file mode 100644 index c396c132..00000000 --- a/runtime/tests/math/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -default: tests - -tests: - tclsh all.tcl - diff --git a/runtime/tests/math/all.tcl b/runtime/tests/math/all.tcl deleted file mode 100644 index 23757202..00000000 --- a/runtime/tests/math/all.tcl +++ /dev/null @@ -1,4 +0,0 @@ -package require tcltest -namespace import -force tcltest::* -tcltest::testsDirectory [file dir [info script]] -tcltest::runAllTests diff --git a/runtime/tests/math/div64.c b/runtime/tests/math/div64.c deleted file mode 100644 index ed033d5b..00000000 --- a/runtime/tests/math/div64.c +++ /dev/null @@ -1,182 +0,0 @@ -/* test of 64-bit division */ -#include "runtime.h" -#define LLONG_MAX 0x7fffffffffffffffLL -#ifndef LLONG_MIN -#define LLONG_MIN 0x8000000000000000LL -#endif - -/* This tests a lot of edge conditions.*/ -/* Then it does 10 million random divisions, comparing the result */ -/* with the results from glibc */ - -int main() -{ - int64_t x, y, div1, mod1, div2, mod2; - const char *error; - int i; - - x = 0; - y = 0; - div1 = _stp_div64(&error, x, y); - if (div1 != 0 || *error != 'd') { - printf("Failed 0/0 test\n"); - exit(-1); - } - error = ""; - - mod1 = _stp_mod64(&error, x, y); - if (mod1 != 0 || *error != 'd') { - printf("Failed 0%0 test\n"); - exit(-1); - } - error = ""; - - x = 1; - y = 0; - div1 = _stp_div64(&error, x, y); - if (div1 != 0 || *error != 'd') { - printf("Failed 1/0 test\n"); - exit(-1); - } - error = ""; - - mod1 = _stp_mod64(&error, x, y); - if (mod1 != 0 || *error != 'd') { - printf("Failed 1%0 test\n"); - exit(-1); - } - error = ""; - - x = 0; - y = 1; - - div1 = _stp_div64(&error, x, y); - if (*error || div1 != 0) { - printf("Failed 0/1 test\n"); - exit(-1); - } - - mod1 = _stp_mod64(&error, x, y); - if (*error || mod1 != 0) { - printf("Failed 0%1 test\n"); - exit(-1); - } - - x = -1; - y = -1; - - div1 = _stp_div64(&error, x, y); - if (*error || div1 != 1) { - printf("Failed -1/-1 test\n"); - exit(-1); - } - - mod1 = _stp_mod64(&error, x, y); - if (*error || mod1 != 0) { - printf("Failed -1%-1 test\n"); - exit(-1); - } - - - for (y = -1; y < 2; y++) { - if (y == 0) - continue; - -#ifndef __LP64__ - for (x = LONG_MIN - 1LL; x < LONG_MIN + 2LL; x++ ) { - div1 = _stp_div64(&error, x, y); - mod1 = _stp_mod64(&error, x, y); - div2 = x/y; - mod2 = x%y; - if (div1 != div2) { - printf ("%lld/%lld (%llx/%llx) was %lld and should have been %lld\n", x,y,x,y,div1,div2); - exit (-1); - } - if (mod1 != mod2) { - printf ("%lld\%%%lld (%llx/%llx) was %lld and should have been %lld\n", x,y,x,y,mod1,mod2); - exit (-1); - } - } - - for (x = LONG_MAX - 1LL; x < LONG_MAX + 2LL; x++ ) { - div1 = _stp_div64(&error, x, y); - mod1 = _stp_mod64(&error, x, y); - div2 = x/y; - mod2 = x%y; - if (div1 != div2) { - printf ("%lld/%lld (%llx/%llx) was %lld and should have been %lld\n", x,y,x,y,div1,div2); - exit (-1); - } - if (mod1 != mod2) { - printf ("%lld\%%%lld (%llx/%llx) was %lld and should have been %lld\n", x,y,x,y,mod1,mod2); - exit (-1); - } - } -#endif - - for (x = LLONG_MIN; x <= LLONG_MIN + 1LL; x++ ) { - div1 = _stp_div64(&error, x, y); - mod1 = _stp_mod64(&error, x, y); -#ifdef __LP64__ - if (x == LLONG_MIN && y == -1) { - if (div1 != LLONG_MIN) { - printf ("%lld/%lld was %lld and should have been %lld (overflow)\n", x,y,div1,LLONG_MIN); - exit(-1); - } - continue; - } -#endif - div2 = x/y; - mod2 = x%y; - if (div1 != div2) { - printf ("%lld/%lld was %lld and should have been %lld\n", x,y,div1,div2); - exit (-1); - } - if (mod1 != mod2) { - printf ("%lld\%%%lld was %lld and should have been %lld\n", x,y,mod1,mod2); - exit (-1); - } - } - - for (x = LONG_MAX - 1; x > 0 && x <= LONG_MAX; x++ ) { - div1 = _stp_div64(&error, x, y); - mod1 = _stp_mod64(&error, x, y); - div2 = x/y; - mod2 = x%y; - if (div1 != div2) { - printf ("%lld/%lld was %lld and should have been %lld\n", x,y,div1,div2); - exit (-1); - } - if (mod1 != mod2) { - printf ("%lld\%%%lld was %lld and should have been %lld\n", x,y,mod1,mod2); - exit (-1); - } - } - } - - /* just for fun, do ten million random divisions and mods */ - for (i = 0; i < 10000000; i++) { - x = mrand48(); - y = mrand48(); - if (y == 0) { - i--; - continue; - } - - div1 = _stp_div64(NULL, x, y); - mod1 = _stp_mod64(NULL, x, y); - div2 = x/y; - mod2 = x%y; - - if (div1 != div2) { - printf ("%lld/%lld was %lld and should have been %lld\n", x,y,div1,div2); - exit (-1); - } - if (mod1 != mod2) { - printf ("%lld\%%%lld was %lld and should have been %lld\n", x,y,mod1,mod2); - exit (-1); - } - } - printf("OK\n"); - return 0; -} diff --git a/runtime/tests/math/math.test b/runtime/tests/math/math.test deleted file mode 100644 index e7c58ba0..00000000 --- a/runtime/tests/math/math.test +++ /dev/null @@ -1,19 +0,0 @@ -package require tcltest -namespace import -force tcltest::* - -cd $tcltest::testsDirectory - -set CFLAGS "-Os" -set KPATH "/lib/modules/[exec uname -r]/build/include" -set MPATH "/lib/modules/[exec uname -r]/build/include/asm/mach-default" -set PATH "../../user" - -test printf_A {Basic printf test} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test div64.c -} -body { - exec ./test -} -result {OK} - -exec rm test - -cleanupTests diff --git a/runtime/tests/pmaps/Makefile b/runtime/tests/pmaps/Makefile deleted file mode 100644 index c396c132..00000000 --- a/runtime/tests/pmaps/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -default: tests - -tests: - tclsh all.tcl - diff --git a/runtime/tests/pmaps/all.tcl b/runtime/tests/pmaps/all.tcl deleted file mode 100644 index c0b38a0e..00000000 --- a/runtime/tests/pmaps/all.tcl +++ /dev/null @@ -1,5 +0,0 @@ -package require tcltest -namespace import -force tcltest::* -tcltest::testsDirectory [file dir [info script]] -tcltest::runAllTests - diff --git a/runtime/tests/pmaps/ii.c b/runtime/tests/pmaps/ii.c deleted file mode 100644 index dfce0a07..00000000 --- a/runtime/tests/pmaps/ii.c +++ /dev/null @@ -1,59 +0,0 @@ -#include "runtime.h" - -/* test of pmaps with keys of int64 and value of int64 */ - -/* It's not clear this would ever be used in the systemtap language. - It would be useful as an array of counters. */ - -#define VALUE_TYPE INT64 -#define KEY1_TYPE INT64 -#include "pmap-gen.c" - -#include "map.c" - -int main () -{ - PMAP map = _stp_pmap_new_ii(4); - int64_t x; - - /* put some data in. _processor_number is a global hack that allows */ - /* us to set the current emulated cpu number for our userspace tests. */ - /* Note that we set values based on the cpu number just to show that */ - /* different values are stored in each cpu */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - _stp_pmap_add_ii(map, 1, _processor_number); - _stp_pmap_add_ii(map, 2, 10 *_processor_number + 1); - _stp_pmap_add_ii(map, 3, _processor_number * _processor_number); - _stp_pmap_add_ii(map, 4, 1); - } - - /* read it back out and verify. Use the special get_cpu call to get non-aggregated data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - x = _stp_pmap_get_cpu_ii (map, 3); - if (x != _processor_number * _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(_processor_number * _processor_number)); - x = _stp_pmap_get_cpu_ii (map, 1); - if (x != _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)_processor_number); - x = _stp_pmap_get_cpu_ii (map, 2); - if (x != 10 * _processor_number + 1) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(10 * _processor_number + 1)); - x = _stp_pmap_get_cpu_ii (map, 4); - if (x != 1LL) - printf("ERROR: Got %lld when expected %lld\n", x, 1LL); - } - - /* now print the per-cpu data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - printf("CPU #%d\n", _processor_number); - _stp_pmap_printn_cpu (map,0, "map[%1d] = %d", _processor_number); - } - _processor_number = 0; - - /* print the aggregated data */ - _stp_pmap_print(map,"map[%1d] = %d"); - - _stp_pmap_del (map); - return 0; -} - diff --git a/runtime/tests/pmaps/ii2.c b/runtime/tests/pmaps/ii2.c deleted file mode 100644 index 0a28ad87..00000000 --- a/runtime/tests/pmaps/ii2.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "runtime.h" - -/* test of maps and pmaps with keys of int64 and value of int64 */ - -/* Make sure we can cleanly generate both */ - -#define VALUE_TYPE INT64 -#define KEY1_TYPE INT64 -#include "pmap-gen.c" - -#define VALUE_TYPE INT64 -#define KEY1_TYPE INT64 -#include "map-gen.c" - -#include "map.c" - -int main () -{ - MAP map = _stp_map_new_ii(4); - PMAP pmap = _stp_pmap_new_ii(4); - int64_t x; - - /* put some data in. _processor_number is a global hack that allows */ - /* us to set the current emulated cpu number for our userspace tests. */ - /* Note that we set values based on the cpu number just to show that */ - /* different values are stored in each cpu */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - _stp_pmap_add_ii(pmap, 1, _processor_number); - _stp_pmap_add_ii(pmap, 2, 10 *_processor_number + 1); - _stp_pmap_add_ii(pmap, 3, _processor_number * _processor_number); - _stp_pmap_add_ii(pmap, 4, 1); - _stp_map_add_ii(map, 1, _processor_number); - _stp_map_add_ii(map, 2, 10 *_processor_number + 1); - _stp_map_add_ii(map, 3, _processor_number * _processor_number); - _stp_map_add_ii(map, 4, 1); - } - - _processor_number = 0; - - /* print the aggregated data */ - _stp_map_print(map,"map[%1d] = %d"); - _stp_pmap_print(pmap,"pmap[%1d] = %d"); - - _stp_map_del (map); - _stp_pmap_del (pmap); - return 0; -} - diff --git a/runtime/tests/pmaps/ii3.c b/runtime/tests/pmaps/ii3.c deleted file mode 100644 index e2dee7a6..00000000 --- a/runtime/tests/pmaps/ii3.c +++ /dev/null @@ -1,59 +0,0 @@ -#include "runtime.h" - -/* test of pmaps with keys of int64 and value of int64 */ - -/* It's not clear this would ever be used in the systemtap language. - It would be useful as an array of counters. */ - -#define VALUE_TYPE INT64 -#define KEY1_TYPE INT64 -#include "pmap-gen.c" - -#include "map.c" - -int main () -{ - PMAP map = _stp_pmap_new_ii(4); - int i; - - /* put some data in. _processor_number is a global hack that allows */ - /* us to set the current emulated cpu number for our userspace tests. */ - /* Note that we set values based on the cpu number just to show that */ - /* different values are stored in each cpu */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - _stp_pmap_add_ii(map, 1, _processor_number); - _stp_pmap_add_ii(map, 2, 10 *_processor_number + 1); - _stp_pmap_add_ii(map, 3, _processor_number * _processor_number); - _stp_pmap_add_ii(map, 4, 1); - } - - _processor_number = 0; - - /* get the data with get calls. this is not very efficient */ - for (i = 1; i < 5; i++) - printf("map[%d] = %lld\n", i, _stp_pmap_get_ii(map, i)); - printf("\n"); - - /* do it again. test that the aggregation map got cleared */ - for (i = 1; i < 5; i++) - printf("map[%d] = %lld\n", i, _stp_pmap_get_ii(map, i)); - printf("\n"); - - /* print the aggregated data */ - _stp_pmap_print(map,"map[%1d] = %d"); - - /* delete an entry and repeat */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) - _stp_pmap_set_ii(map, 2, 0); - _processor_number = 0; - - for (i = 1; i < 5; i++) - printf("map[%d] = %lld\n", i, _stp_pmap_get_ii(map, i)); - printf("\n"); - - _stp_pmap_print(map,"map[%1d] = %d"); - - _stp_pmap_del (map); - return 0; -} - diff --git a/runtime/tests/pmaps/is.c b/runtime/tests/pmaps/is.c deleted file mode 100644 index a97d8b0b..00000000 --- a/runtime/tests/pmaps/is.c +++ /dev/null @@ -1,67 +0,0 @@ -#include "runtime.h" - -/* test of pmaps with keys of int64 and value of string */ - -/* It's not clear this would ever be used in the systemtap language. - It is not clear this would be useful. */ - -#define VALUE_TYPE STRING -#define KEY1_TYPE INT64 -#include "pmap-gen.c" - -#include "map.c" - -int main () -{ - PMAP map = _stp_pmap_new_is(4); - char *x; - char buf[32]; - - /* put some data in. _processor_number is a global hack that allows */ - /* us to set the current emulated cpu number for our userspace tests. */ - /* Note that we set values based on the cpu number just to show that */ - /* different values are stored in each cpu */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - sprintf(buf, "%d,", _processor_number); - _stp_pmap_add_is(map, 1, buf); - sprintf(buf, "%d,", 10 *_processor_number + 1); - _stp_pmap_add_is(map, 2, buf); - sprintf(buf, "%d,", _processor_number * _processor_number); - _stp_pmap_add_is(map, 3, buf); - _stp_pmap_add_is(map, 4, "1,"); - } - - /* read it back out and verify. Use the special get_cpu call to get non-aggregated data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - x = _stp_pmap_get_cpu_is (map, 3); - sprintf(buf, "%d,", _processor_number * _processor_number); - if (strcmp(x, buf)) - printf("ERROR: Got %s when expected %s\n", x, buf); - x = _stp_pmap_get_cpu_is (map, 1); - sprintf(buf, "%d,", _processor_number); - if (strcmp(x, buf)) - printf("ERROR: Got %s when expected %s\n", x, buf); - x = _stp_pmap_get_cpu_is (map, 4); - sprintf(buf, "%d,", 1); - if (strcmp(x, buf)) - printf("ERROR: Got %s when expected %s\n", x, buf); - x = _stp_pmap_get_cpu_is (map, 2); - sprintf(buf, "%d,", 10 * _processor_number +1); - if (strcmp(x, buf)) - printf("ERROR: Got %s when expected %s\n", x, buf); - } - - /* now print the per-cpu data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - printf("CPU #%d\n", _processor_number); - _stp_pmap_printn_cpu (map,0, "map[%1d] = %s", _processor_number); - } - _processor_number = 0; - - /* print the aggregated data */ - _stp_pmap_print(map,"map[%1d] = %s"); - - _stp_pmap_del (map); - return 0; -} - diff --git a/runtime/tests/pmaps/ix.c b/runtime/tests/pmaps/ix.c deleted file mode 100644 index 0eba2d54..00000000 --- a/runtime/tests/pmaps/ix.c +++ /dev/null @@ -1,61 +0,0 @@ -#include "runtime.h" - -/* test of pmaps with keys of int64 and value of stat */ - -#define VALUE_TYPE STAT -#define KEY1_TYPE INT64 -#include "pmap-gen.c" - -#include "map.c" - -int main () -{ - PMAP map = _stp_pmap_new_ix(4, HIST_LINEAR, 0, 100, 10); - int64_t x; - - /* put some data in. _processor_number is a global hack that allows */ - /* us to set the current emulated cpu number for our userspace tests. */ - /* Note that we set values based on the cpu number just to show that */ - /* different values are stored in each cpu */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - _stp_pmap_add_ix(map, 1, _processor_number); - _stp_pmap_add_ix(map, 2, 10 *_processor_number + 1); - _stp_pmap_add_ix(map, 3, _processor_number * _processor_number); - _stp_pmap_add_ix(map, 4, 1); - } - -#if 0 - /* read it back out and verify. Use the special get_cpu call to get non-aggregated data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - x = _stp_pmap_get_cpu_ix (map, 3); - if (x != _processor_number * _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(_processor_number * _processor_number)); - x = _stp_pmap_get_cpu_ix (map, 1); - if (x != _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)_processor_number); - x = _stp_pmap_get_cpu_ix (map, 2); - if (x != 10 * _processor_number + 1) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(10 * _processor_number + 1)); - x = _stp_pmap_get_cpu_ix (map, 4); - if (x != 1LL) - printf("ERROR: Got %lld when expected %lld\n", x, 1LL); - } -#endif - - /* now print the per-cpu data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - printf("CPU #%d\n", _processor_number); - _stp_pmap_printn_cpu (map, - 0, - "map[%1d] = count:%C sum:%S avg:%A min:%m max:%M", - _processor_number); - } - _processor_number = 0; - - /* print the aggregated data */ - _stp_pmap_print(map,"map[%1d] = count:%C sum:%S avg:%A min:%m max:%M\n%H"); - - _stp_pmap_del (map); - return 0; -} - diff --git a/runtime/tests/pmaps/ix2.c b/runtime/tests/pmaps/ix2.c deleted file mode 100644 index 638e5226..00000000 --- a/runtime/tests/pmaps/ix2.c +++ /dev/null @@ -1,64 +0,0 @@ -#include "runtime.h" - -/* test of pmaps with keys of int64 and value of stat */ - -#define VALUE_TYPE STAT -#define KEY1_TYPE INT64 -#include "pmap-gen.c" - -#include "map.c" - -int main () -{ - PMAP map = _stp_pmap_new_ix(4, HIST_LINEAR, 0, 100, 10); - int i; - - /* put some data in. _processor_number is a global hack that allows */ - /* us to set the current emulated cpu number for our userspace tests. */ - /* Note that we set values based on the cpu number just to show that */ - /* different values are stored in each cpu */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - _stp_pmap_add_ix(map, 1, _processor_number); - _stp_pmap_add_ix(map, 2, 10 *_processor_number + 1); - _stp_pmap_add_ix(map, 3, _processor_number * _processor_number); - _stp_pmap_add_ix(map, 4, 1); - } - - /* now print the per-cpu data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - printf("CPU #%d\n", _processor_number); - _stp_pmap_printn_cpu (map, - 0, - "map[%1d] = count:%C sum:%S avg:%A min:%m max:%M", - _processor_number); - } - _processor_number = 0; - - /* print the aggregated data */ - _stp_pmap_print(map,"map[%1d] = count:%C sum:%S avg:%A min:%m max:%M\n%H"); - - /* now use GET */ - for (i = 1; i < 5; i++) - printf("map[%d] Sum = %lld\n", i, _stp_pmap_get_ix(map, i)->sum); - printf("\n"); - - /* delete an entry and repeat */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) - _stp_pmap_set_ix(map, 2, 0); - _processor_number = 0; - - /* print the aggregated data */ - _stp_pmap_print(map,"map[%1d] = count:%C sum:%S avg:%A min:%m max:%M\n%H"); - - /* now use GET */ - for (i = 1; i < 5; i++) { - stat *sd = _stp_pmap_get_ix(map, i); - if (sd) - printf("map[%d] Sum = %lld\n", i, sd->sum); - } - printf("\n"); - - _stp_pmap_del (map); - return 0; -} - diff --git a/runtime/tests/pmaps/ix_log.c b/runtime/tests/pmaps/ix_log.c deleted file mode 100644 index 4f3c5503..00000000 --- a/runtime/tests/pmaps/ix_log.c +++ /dev/null @@ -1,62 +0,0 @@ -#include "runtime.h" - -/* like ix.c, except use HIST_LOG */ -/* test of pmaps with keys of int64 and value of stat */ - -#define VALUE_TYPE STAT -#define KEY1_TYPE INT64 -#include "pmap-gen.c" - -#include "map.c" - -int main () -{ - PMAP map = _stp_pmap_new_ix(4, HIST_LOG, 5); - int64_t x; - - /* put some data in. _processor_number is a global hack that allows */ - /* us to set the current emulated cpu number for our userspace tests. */ - /* Note that we set values based on the cpu number just to show that */ - /* different values are stored in each cpu */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - _stp_pmap_add_ix(map, 1, _processor_number); - _stp_pmap_add_ix(map, 2, 10 *_processor_number + 1); - _stp_pmap_add_ix(map, 3, _processor_number * _processor_number); - _stp_pmap_add_ix(map, 4, 1); - } - -#if 0 - /* read it back out and verify. Use the special get_cpu call to get non-aggregated data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - x = _stp_pmap_get_cpu_ix (map, 3); - if (x != _processor_number * _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(_processor_number * _processor_number)); - x = _stp_pmap_get_cpu_ix (map, 1); - if (x != _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)_processor_number); - x = _stp_pmap_get_cpu_ix (map, 2); - if (x != 10 * _processor_number + 1) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(10 * _processor_number + 1)); - x = _stp_pmap_get_cpu_ix (map, 4); - if (x != 1LL) - printf("ERROR: Got %lld when expected %lld\n", x, 1LL); - } -#endif - - /* now print the per-cpu data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - printf("CPU #%d\n", _processor_number); - _stp_pmap_printn_cpu (map, - 0, - "map[%1d] = count:%C sum:%S avg:%A min:%m max:%M", - _processor_number); - } - _processor_number = 0; - - /* print the aggregated data */ - _stp_pmap_print(map,"map[%1d] = count:%C sum:%S avg:%A min:%m max:%M\n%H"); - - _stp_pmap_del (map); - return 0; -} - diff --git a/runtime/tests/pmaps/ix_none.c b/runtime/tests/pmaps/ix_none.c deleted file mode 100644 index 440b0069..00000000 --- a/runtime/tests/pmaps/ix_none.c +++ /dev/null @@ -1,62 +0,0 @@ -#include "runtime.h" - -/* like ix.c, except with no histogram */ -/* test of pmaps with keys of int64 and value of stat */ - -#define VALUE_TYPE STAT -#define KEY1_TYPE INT64 -#include "pmap-gen.c" - -#include "map.c" - -int main () -{ - PMAP map = _stp_pmap_new_ix(4, HIST_NONE); - int64_t x; - - /* put some data in. _processor_number is a global hack that allows */ - /* us to set the current emulated cpu number for our userspace tests. */ - /* Note that we set values based on the cpu number just to show that */ - /* different values are stored in each cpu */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - _stp_pmap_add_ix(map, 1, _processor_number); - _stp_pmap_add_ix(map, 2, 10 *_processor_number + 1); - _stp_pmap_add_ix(map, 3, _processor_number * _processor_number); - _stp_pmap_add_ix(map, 4, 1); - } - -#if 0 - /* read it back out and verify. Use the special get_cpu call to get non-aggregated data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - x = _stp_pmap_get_cpu_ix (map, 3); - if (x != _processor_number * _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(_processor_number * _processor_number)); - x = _stp_pmap_get_cpu_ix (map, 1); - if (x != _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)_processor_number); - x = _stp_pmap_get_cpu_ix (map, 2); - if (x != 10 * _processor_number + 1) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(10 * _processor_number + 1)); - x = _stp_pmap_get_cpu_ix (map, 4); - if (x != 1LL) - printf("ERROR: Got %lld when expected %lld\n", x, 1LL); - } -#endif - - /* now print the per-cpu data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - printf("CPU #%d\n", _processor_number); - _stp_pmap_printn_cpu (map, - 0, - "map[%1d] = count:%C sum:%S avg:%A min:%m max:%M", - _processor_number); - } - _processor_number = 0; - - /* print the aggregated data */ - _stp_pmap_print(map,"map[%1d] = count:%C sum:%S avg:%A min:%m max:%M\n%H"); - - _stp_pmap_del (map); - return 0; -} - diff --git a/runtime/tests/pmaps/map_format.c b/runtime/tests/pmaps/map_format.c deleted file mode 100644 index b27506e0..00000000 --- a/runtime/tests/pmaps/map_format.c +++ /dev/null @@ -1,92 +0,0 @@ -#include "runtime.h" - -/* map formatting test. Same as the non-pmap version. Output should be identical */ - -/* torture test of map formatting */ -#define VALUE_TYPE STRING -#define KEY1_TYPE INT64 -#define KEY2_TYPE INT64 -#define KEY3_TYPE STRING -#include "pmap-gen.c" - -#define VALUE_TYPE INT64 -#define KEY1_TYPE STRING -#define KEY2_TYPE STRING -#include "pmap-gen.c" - -#define VALUE_TYPE STAT -#define KEY1_TYPE STRING -#define KEY2_TYPE STRING -#include "pmap-gen.c" - -#include "map.c" - -void inc_cpu(void) -{ - _processor_number++; - if (_processor_number == NR_CPUS) - _processor_number = 0; -} - -int main () -{ - PMAP mapiis = _stp_pmap_new_iiss(4); - _processor_number = 0; - _stp_pmap_set_iiss (mapiis, 1,2,"Ohio", "Columbus" ); - _stp_pmap_set_iiss (mapiis, 3,4,"California", "Sacramento" ); - _stp_pmap_set_iiss (mapiis, 5,6,"Washington", "Olympia" ); - _stp_pmap_set_iiss (mapiis, 7,8,"Oregon", "Salem" ); - _stp_pmap_print (mapiis, "%s -> mapiis %1d %2d %3s"); - - /* test printing of '%' */ - _stp_pmap_print (mapiis, "%s %% %3s"); - - /* very bad string. don't crash */ - _stp_pmap_print (mapiis, "%s -> mapiis %1s %2s %3d %4d"); - - PMAP mapss = _stp_pmap_new_ssi(4); - _stp_pmap_set_ssi (mapss, "Riga", "Latvia", 0x0000c0dedbad0000LL); - _stp_pmap_set_ssi (mapss, "Sofia", "Bulgaria", 0xdeadf00d12345678LL); - _stp_pmap_set_ssi (mapss, "Valletta", "Malta", 1); - _stp_pmap_set_ssi (mapss, "Nicosia", "Cyprus", -1); - _stp_pmap_print (mapss, "The capitol of %1s is %2s and the nerd population is %d"); - _stp_pmap_print (mapss, "The capitol of %1s is %2s and the nerd population is %x"); - _stp_pmap_print (mapss, "The capitol of %1s is %2s and the nerd population is %X"); - - PMAP mapssx = _stp_pmap_new_ssx (4, HIST_LINEAR, 0, 100, 10 ); - int i,j; - - for (i = 0; i < 100; i++) - for (j = 0; j <= i*10 ; j++ ) { - inc_cpu(); - _stp_pmap_add_ssx (mapssx, "Riga", "Latvia", i); - } - - for (i = 0; i < 10; i++) - for (j = 0; j < 10 ; j++ ) { - inc_cpu(); - _stp_pmap_add_ssx (mapssx, "Sofia", "Bulgaria", j * i ); - } - - for (i = 0; i < 100; i += 10) - for (j = 0; j < i/10 ; j++ ) { - inc_cpu(); - _stp_pmap_add_ssx (mapssx, "Valletta", "Malta", i); - } - - _stp_pmap_print (mapssx, "Bogons per packet for %1s\ncount:%C sum:%S avg:%A min:%m max:%M\n%H"); - - _stp_pmap_print (mapssx, "%C was the count for %1s, %2s"); - - /* here's how to print a map without using _stp_pmap_print(). */ - _stp_pmap_agg (mapssx); - struct map_node *ptr; - foreach (_stp_pmap_get_agg(mapssx), ptr) - _stp_printf ("mapssx[%09s,%09s] = %llX\n", key1str(ptr), key2str(ptr), _stp_get_stat(ptr)->sum); - _stp_print_flush(); - - _stp_pmap_del (mapssx); - _stp_pmap_del (mapiis); - _stp_pmap_del (mapss); - return 0; -} diff --git a/runtime/tests/pmaps/pmap.test b/runtime/tests/pmaps/pmap.test deleted file mode 100644 index fb5c3d0d..00000000 --- a/runtime/tests/pmaps/pmap.test +++ /dev/null @@ -1,678 +0,0 @@ -package require tcltest -namespace import -force tcltest::* - -cd $tcltest::testsDirectory - -set CFLAGS "-Os" -set KPATH "/lib/modules/[exec uname -r]/build/include" -set MPATH "/lib/modules/[exec uname -r]/build/include/asm/mach-default" -set PATH "../../user" - -test ii {Test of int64 keys and int64 values} -setup { - puts "gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ii.c" - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ii.c -} -body { - exec ./test -} -result {CPU #0 -map[2] = 1 -map[4] = 1 - -CPU #1 -map[1] = 1 -map[2] = 11 -map[3] = 1 -map[4] = 1 - -CPU #2 -map[1] = 2 -map[2] = 21 -map[3] = 4 -map[4] = 1 - -CPU #3 -map[1] = 3 -map[2] = 31 -map[3] = 9 -map[4] = 1 - -CPU #4 -map[1] = 4 -map[2] = 41 -map[3] = 16 -map[4] = 1 - -CPU #5 -map[1] = 5 -map[2] = 51 -map[3] = 25 -map[4] = 1 - -CPU #6 -map[1] = 6 -map[2] = 61 -map[3] = 36 -map[4] = 1 - -CPU #7 -map[1] = 7 -map[2] = 71 -map[3] = 49 -map[4] = 1 - -map[2] = 288 -map[4] = 8 -map[1] = 28 -map[3] = 140 -} - -test is {Test of int64 keys and string values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test is.c -} -body { - exec ./test -} -result {CPU #0 -map[1] = 0, -map[2] = 1, -map[3] = 0, -map[4] = 1, - -CPU #1 -map[1] = 1, -map[2] = 11, -map[3] = 1, -map[4] = 1, - -CPU #2 -map[1] = 2, -map[2] = 21, -map[3] = 4, -map[4] = 1, - -CPU #3 -map[1] = 3, -map[2] = 31, -map[3] = 9, -map[4] = 1, - -CPU #4 -map[1] = 4, -map[2] = 41, -map[3] = 16, -map[4] = 1, - -CPU #5 -map[1] = 5, -map[2] = 51, -map[3] = 25, -map[4] = 1, - -CPU #6 -map[1] = 6, -map[2] = 61, -map[3] = 36, -map[4] = 1, - -CPU #7 -map[1] = 7, -map[2] = 71, -map[3] = 49, -map[4] = 1, - -map[2] = 1,11,21,31,41,51,61,71, -map[4] = 1,1,1,1,1,1,1,1, -map[1] = 0,1,2,3,4,5,6,7, -map[3] = 0,1,4,9,16,25,36,49, -} - -test si {Test of string keys and int64 values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test si.c -} -body { - exec ./test -} -result {CPU #0 -map[TWO] = 1 -map[FOUR] = 1 - -CPU #1 -map[ONE] = 1 -map[TWO] = 11 -map[THREE] = 1 -map[FOUR] = 1 - -CPU #2 -map[ONE] = 2 -map[TWO] = 21 -map[THREE] = 4 -map[FOUR] = 1 - -CPU #3 -map[ONE] = 3 -map[TWO] = 31 -map[THREE] = 9 -map[FOUR] = 1 - -CPU #4 -map[ONE] = 4 -map[TWO] = 41 -map[THREE] = 16 -map[FOUR] = 1 - -CPU #5 -map[ONE] = 5 -map[TWO] = 51 -map[THREE] = 25 -map[FOUR] = 1 - -CPU #6 -map[ONE] = 6 -map[TWO] = 61 -map[THREE] = 36 -map[FOUR] = 1 - -CPU #7 -map[ONE] = 7 -map[TWO] = 71 -map[THREE] = 49 -map[FOUR] = 1 - -map[FOUR] = 8 -map[TWO] = 288 -map[THREE] = 140 -map[ONE] = 28 -} - -test ix {Test of int64 keys and stat values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ix.c -} -body { - exec ./test -} -result {CPU #0 -map[1] = count:1 sum:0 avg:0 min:0 max:0 -map[2] = count:1 sum:1 avg:1 min:1 max:1 -map[3] = count:1 sum:0 avg:0 min:0 max:0 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #1 -map[1] = count:1 sum:1 avg:1 min:1 max:1 -map[2] = count:1 sum:11 avg:11 min:11 max:11 -map[3] = count:1 sum:1 avg:1 min:1 max:1 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #2 -map[1] = count:1 sum:2 avg:2 min:2 max:2 -map[2] = count:1 sum:21 avg:21 min:21 max:21 -map[3] = count:1 sum:4 avg:4 min:4 max:4 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #3 -map[1] = count:1 sum:3 avg:3 min:3 max:3 -map[2] = count:1 sum:31 avg:31 min:31 max:31 -map[3] = count:1 sum:9 avg:9 min:9 max:9 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #4 -map[1] = count:1 sum:4 avg:4 min:4 max:4 -map[2] = count:1 sum:41 avg:41 min:41 max:41 -map[3] = count:1 sum:16 avg:16 min:16 max:16 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #5 -map[1] = count:1 sum:5 avg:5 min:5 max:5 -map[2] = count:1 sum:51 avg:51 min:51 max:51 -map[3] = count:1 sum:25 avg:25 min:25 max:25 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #6 -map[1] = count:1 sum:6 avg:6 min:6 max:6 -map[2] = count:1 sum:61 avg:61 min:61 max:61 -map[3] = count:1 sum:36 avg:36 min:36 max:36 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #7 -map[1] = count:1 sum:7 avg:7 min:7 max:7 -map[2] = count:1 sum:71 avg:71 min:71 max:71 -map[3] = count:1 sum:49 avg:49 min:49 max:49 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -map[2] = count:8 sum:288 avg:36 min:1 max:71 -value |-------------------------------------------------- count - 0 |@ 1 - 10 |@ 1 - 20 |@ 1 - 30 |@ 1 - 40 |@ 1 - 50 |@ 1 - 60 |@ 1 - 70 |@ 1 - 80 | 0 - 90 | 0 - -map[4] = count:8 sum:8 avg:1 min:1 max:1 -value |-------------------------------------------------- count - 0 |@@@@@@@@ 8 - 10 | 0 - 20 | 0 - -map[1] = count:8 sum:28 avg:3 min:0 max:7 -value |-------------------------------------------------- count - 0 |@@@@@@@@ 8 - 10 | 0 - 20 | 0 - -map[3] = count:8 sum:140 avg:17 min:0 max:49 -value |-------------------------------------------------- count - 0 |@@@@ 4 - 10 |@ 1 - 20 |@ 1 - 30 |@ 1 - 40 |@ 1 - 50 | 0 - 60 | 0 - -} - -test ix_log {Test of int64 keys and stat values (log histogram)} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ix_log.c -} -body { - exec ./test -} -result {CPU #0 -map[1] = count:1 sum:0 avg:0 min:0 max:0 -map[2] = count:1 sum:1 avg:1 min:1 max:1 -map[3] = count:1 sum:0 avg:0 min:0 max:0 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #1 -map[1] = count:1 sum:1 avg:1 min:1 max:1 -map[2] = count:1 sum:11 avg:11 min:11 max:11 -map[3] = count:1 sum:1 avg:1 min:1 max:1 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #2 -map[1] = count:1 sum:2 avg:2 min:2 max:2 -map[2] = count:1 sum:21 avg:21 min:21 max:21 -map[3] = count:1 sum:4 avg:4 min:4 max:4 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #3 -map[1] = count:1 sum:3 avg:3 min:3 max:3 -map[2] = count:1 sum:31 avg:31 min:31 max:31 -map[3] = count:1 sum:9 avg:9 min:9 max:9 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #4 -map[1] = count:1 sum:4 avg:4 min:4 max:4 -map[2] = count:1 sum:41 avg:41 min:41 max:41 -map[3] = count:1 sum:16 avg:16 min:16 max:16 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #5 -map[1] = count:1 sum:5 avg:5 min:5 max:5 -map[2] = count:1 sum:51 avg:51 min:51 max:51 -map[3] = count:1 sum:25 avg:25 min:25 max:25 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #6 -map[1] = count:1 sum:6 avg:6 min:6 max:6 -map[2] = count:1 sum:61 avg:61 min:61 max:61 -map[3] = count:1 sum:36 avg:36 min:36 max:36 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #7 -map[1] = count:1 sum:7 avg:7 min:7 max:7 -map[2] = count:1 sum:71 avg:71 min:71 max:71 -map[3] = count:1 sum:49 avg:49 min:49 max:49 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -map[2] = count:8 sum:288 avg:36 min:1 max:71 -value |-------------------------------------------------- count - 0 | 0 - 1 |@ 1 - 2 | 0 - 4 | 0 - 8 |@@@@@@@ 7 - -map[4] = count:8 sum:8 avg:1 min:1 max:1 -value |-------------------------------------------------- count - 0 | 0 - 1 |@@@@@@@@ 8 - 2 | 0 - 4 | 0 - -map[1] = count:8 sum:28 avg:3 min:0 max:7 -value |-------------------------------------------------- count - 0 |@ 1 - 1 |@ 1 - 2 |@@ 2 - 4 |@@@@ 4 - 8 | 0 - -map[3] = count:8 sum:140 avg:17 min:0 max:49 -value |-------------------------------------------------- count - 0 |@ 1 - 1 |@ 1 - 2 | 0 - 4 |@ 1 - 8 |@@@@@ 5 - -} - -test ix_none {Test of int64 keys and stat values (no histogram)} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ix_none.c -} -body { - exec ./test -} -result {CPU #0 -map[1] = count:1 sum:0 avg:0 min:0 max:0 -map[2] = count:1 sum:1 avg:1 min:1 max:1 -map[3] = count:1 sum:0 avg:0 min:0 max:0 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #1 -map[1] = count:1 sum:1 avg:1 min:1 max:1 -map[2] = count:1 sum:11 avg:11 min:11 max:11 -map[3] = count:1 sum:1 avg:1 min:1 max:1 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #2 -map[1] = count:1 sum:2 avg:2 min:2 max:2 -map[2] = count:1 sum:21 avg:21 min:21 max:21 -map[3] = count:1 sum:4 avg:4 min:4 max:4 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #3 -map[1] = count:1 sum:3 avg:3 min:3 max:3 -map[2] = count:1 sum:31 avg:31 min:31 max:31 -map[3] = count:1 sum:9 avg:9 min:9 max:9 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #4 -map[1] = count:1 sum:4 avg:4 min:4 max:4 -map[2] = count:1 sum:41 avg:41 min:41 max:41 -map[3] = count:1 sum:16 avg:16 min:16 max:16 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #5 -map[1] = count:1 sum:5 avg:5 min:5 max:5 -map[2] = count:1 sum:51 avg:51 min:51 max:51 -map[3] = count:1 sum:25 avg:25 min:25 max:25 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #6 -map[1] = count:1 sum:6 avg:6 min:6 max:6 -map[2] = count:1 sum:61 avg:61 min:61 max:61 -map[3] = count:1 sum:36 avg:36 min:36 max:36 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #7 -map[1] = count:1 sum:7 avg:7 min:7 max:7 -map[2] = count:1 sum:71 avg:71 min:71 max:71 -map[3] = count:1 sum:49 avg:49 min:49 max:49 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -map[2] = count:8 sum:288 avg:36 min:1 max:71 - -map[4] = count:8 sum:8 avg:1 min:1 max:1 - -map[1] = count:8 sum:28 avg:3 min:0 max:7 - -map[3] = count:8 sum:140 avg:17 min:0 max:49 - -} - -test map_format {Test of map formatting and histograms} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test map_format.c -} -body { - exec ./test -} -result {Columbus -> mapiis 1 2 Ohio -Salem -> mapiis 7 8 Oregon -Olympia -> mapiis 5 6 Washington -Sacramento -> mapiis 3 4 California - -Columbus % Ohio -Salem % Oregon -Olympia % Washington -Sacramento % California - -Columbus -> mapiis -Salem -> mapiis -Olympia -> mapiis -Sacramento -> mapiis - -The capitol of Riga is Latvia and the nerd population is 212063400820736 -The capitol of Sofia is Bulgaria and the nerd population is -2400999087387945352 -The capitol of Nicosia is Cyprus and the nerd population is -1 -The capitol of Valletta is Malta and the nerd population is 1 - -The capitol of Riga is Latvia and the nerd population is c0dedbad0000 -The capitol of Sofia is Bulgaria and the nerd population is deadf00d12345678 -The capitol of Nicosia is Cyprus and the nerd population is ffffffffffffffff -The capitol of Valletta is Malta and the nerd population is 1 - -The capitol of Riga is Latvia and the nerd population is C0DEDBAD0000 -The capitol of Sofia is Bulgaria and the nerd population is DEADF00D12345678 -The capitol of Nicosia is Cyprus and the nerd population is FFFFFFFFFFFFFFFF -The capitol of Valletta is Malta and the nerd population is 1 - -Bogons per packet for Riga -count:49600 sum:3288450 avg:66 min:0 max:99 -value |-------------------------------------------------- count - 0 |@@ 460 - 10 |@@@@@@@ 1460 - 20 |@@@@@@@@@@@@ 2460 - 30 |@@@@@@@@@@@@@@@@@@ 3460 - 40 |@@@@@@@@@@@@@@@@@@@@@@@ 4460 - 50 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5460 - 60 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6460 - 70 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7460 - 80 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8460 - 90 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9460 - -Bogons per packet for Sofia -count:100 sum:2025 avg:20 min:0 max:81 -value |-------------------------------------------------- count - 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 42 - 10 |@@@@@@@@@@@@@@@@@ 17 - 20 |@@@@@@@@@@@@@ 13 - 30 |@@@@@@@@@ 9 - 40 |@@@@@@@@@ 9 - 50 |@@@@ 4 - 60 |@@@ 3 - 70 |@@ 2 - 80 |@ 1 - 90 | 0 - -Bogons per packet for Valletta -count:45 sum:2850 avg:63 min:10 max:90 -value |-------------------------------------------------- count - 0 | 0 - 10 |@ 1 - 20 |@@ 2 - 30 |@@@ 3 - 40 |@@@@ 4 - 50 |@@@@@ 5 - 60 |@@@@@@ 6 - 70 |@@@@@@@ 7 - 80 |@@@@@@@@ 8 - 90 |@@@@@@@@@ 9 - - -49600 was the count for Riga, Latvia -100 was the count for Sofia, Bulgaria -45 was the count for Valletta, Malta - -mapssx[ Riga, Latvia] = 322D82 -mapssx[ Sofia, Bulgaria] = 7E9 -mapssx[ Valletta, Malta] = B22} - - -test ii2 {Test of maps and pmaps with int64 keys and int64 values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ii2.c -} -body { - exec ./test -} -result {map[2] = 288 -map[4] = 8 -map[1] = 28 -map[3] = 140 - -pmap[2] = 288 -pmap[4] = 8 -pmap[1] = 28 -pmap[3] = 140 -} - -test ii3 {Test of int64 keys and int64 values with GET} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ii3.c -} -body { - exec ./test -} -result {map[1] = 28 -map[2] = 288 -map[3] = 140 -map[4] = 8 - -map[1] = 28 -map[2] = 288 -map[3] = 140 -map[4] = 8 - -map[2] = 288 -map[4] = 8 -map[1] = 28 -map[3] = 140 - -map[1] = 28 -map[2] = 0 -map[3] = 140 -map[4] = 8 - -map[4] = 8 -map[1] = 28 -map[3] = 140 -} - -test ix2 {Test of int64 keys and sttat values with GET} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ix2.c -} -body { - exec ./test -} -result {CPU #0 -map[1] = count:1 sum:0 avg:0 min:0 max:0 -map[2] = count:1 sum:1 avg:1 min:1 max:1 -map[3] = count:1 sum:0 avg:0 min:0 max:0 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #1 -map[1] = count:1 sum:1 avg:1 min:1 max:1 -map[2] = count:1 sum:11 avg:11 min:11 max:11 -map[3] = count:1 sum:1 avg:1 min:1 max:1 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #2 -map[1] = count:1 sum:2 avg:2 min:2 max:2 -map[2] = count:1 sum:21 avg:21 min:21 max:21 -map[3] = count:1 sum:4 avg:4 min:4 max:4 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #3 -map[1] = count:1 sum:3 avg:3 min:3 max:3 -map[2] = count:1 sum:31 avg:31 min:31 max:31 -map[3] = count:1 sum:9 avg:9 min:9 max:9 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #4 -map[1] = count:1 sum:4 avg:4 min:4 max:4 -map[2] = count:1 sum:41 avg:41 min:41 max:41 -map[3] = count:1 sum:16 avg:16 min:16 max:16 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #5 -map[1] = count:1 sum:5 avg:5 min:5 max:5 -map[2] = count:1 sum:51 avg:51 min:51 max:51 -map[3] = count:1 sum:25 avg:25 min:25 max:25 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #6 -map[1] = count:1 sum:6 avg:6 min:6 max:6 -map[2] = count:1 sum:61 avg:61 min:61 max:61 -map[3] = count:1 sum:36 avg:36 min:36 max:36 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -CPU #7 -map[1] = count:1 sum:7 avg:7 min:7 max:7 -map[2] = count:1 sum:71 avg:71 min:71 max:71 -map[3] = count:1 sum:49 avg:49 min:49 max:49 -map[4] = count:1 sum:1 avg:1 min:1 max:1 - -map[2] = count:8 sum:288 avg:36 min:1 max:71 -value |-------------------------------------------------- count - 0 |@ 1 - 10 |@ 1 - 20 |@ 1 - 30 |@ 1 - 40 |@ 1 - 50 |@ 1 - 60 |@ 1 - 70 |@ 1 - 80 | 0 - 90 | 0 - -map[4] = count:8 sum:8 avg:1 min:1 max:1 -value |-------------------------------------------------- count - 0 |@@@@@@@@ 8 - 10 | 0 - 20 | 0 - -map[1] = count:8 sum:28 avg:3 min:0 max:7 -value |-------------------------------------------------- count - 0 |@@@@@@@@ 8 - 10 | 0 - 20 | 0 - -map[3] = count:8 sum:140 avg:17 min:0 max:49 -value |-------------------------------------------------- count - 0 |@@@@ 4 - 10 |@ 1 - 20 |@ 1 - 30 |@ 1 - 40 |@ 1 - 50 | 0 - 60 | 0 - - -map[1] Sum = 28 -map[2] Sum = 288 -map[3] Sum = 140 -map[4] Sum = 8 - -map[4] = count:8 sum:8 avg:1 min:1 max:1 -value |-------------------------------------------------- count - 0 |@@@@@@@@ 8 - 10 | 0 - 20 | 0 - -map[1] = count:8 sum:28 avg:3 min:0 max:7 -value |-------------------------------------------------- count - 0 |@@@@@@@@ 8 - 10 | 0 - 20 | 0 - -map[3] = count:8 sum:140 avg:17 min:0 max:49 -value |-------------------------------------------------- count - 0 |@@@@ 4 - 10 |@ 1 - 20 |@ 1 - 30 |@ 1 - 40 |@ 1 - 50 | 0 - 60 | 0 - - -map[1] Sum = 28 -map[3] Sum = 140 -map[4] Sum = 8 -} - - -test size {Test _stp_pmap_size()} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test size.c -} -body { - exec ./test -} -result {} - -catch {exec rm test} - -cleanupTests diff --git a/runtime/tests/pmaps/si.c b/runtime/tests/pmaps/si.c deleted file mode 100644 index 8b05da74..00000000 --- a/runtime/tests/pmaps/si.c +++ /dev/null @@ -1,62 +0,0 @@ -#include "runtime.h" - -/* test of pmaps with keys of string and value of int64 */ - -/* It's not clear this would ever be used in the systemtap language. - It would be useful as an array of counters. */ - -#define VALUE_TYPE INT64 -#define KEY1_TYPE STRING -#include "pmap-gen.c" - -#include "map.c" - -int main () -{ - PMAP map = _stp_pmap_new_si(4); - int64_t x; - - if (!map) - return -1; - - /* put some data in. _processor_number is a global hack that allows */ - /* us to set the current emulated cpu number for our userspace tests. */ - /* Note that we set values based on the cpu number just to show that */ - /* different values are stored in each cpu */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - _stp_pmap_add_si(map, "ONE", _processor_number); - _stp_pmap_add_si(map, "TWO", 10 *_processor_number + 1); - _stp_pmap_add_si(map, "THREE", _processor_number * _processor_number); - _stp_pmap_add_si(map, "FOUR", 1); - } - - /* read it back out and verify. Use the special get_cpu call to get non-aggregated data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - x = _stp_pmap_get_cpu_si (map, "THREE"); - if (x != _processor_number * _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(_processor_number * _processor_number)); - x = _stp_pmap_get_cpu_si (map, "ONE"); - if (x != _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)_processor_number); - x = _stp_pmap_get_cpu_si (map, "TWO"); - if (x != 10 * _processor_number + 1) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(10 * _processor_number + 1)); - x = _stp_pmap_get_cpu_si (map, "FOUR"); - if (x != 1LL) - printf("ERROR: Got %lld when expected %lld\n", x, 1LL); - } - - /* now print the per-cpu data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - printf("CPU #%d\n", _processor_number); - _stp_pmap_printn_cpu (map,0, "map[%1s] = %d", _processor_number); - } - _processor_number = 0; - - /* print the aggregated data */ - _stp_pmap_print(map,"map[%1s] = %d"); - - _stp_pmap_del (map); - return 0; -} - diff --git a/runtime/tests/pmaps/size.c b/runtime/tests/pmaps/size.c deleted file mode 100644 index be8b4590..00000000 --- a/runtime/tests/pmaps/size.c +++ /dev/null @@ -1,72 +0,0 @@ -#include "runtime.h" - -/* test of _stp_pmap_size() */ - -/* It's not clear this would ever be used in the systemtap language. - It would be useful as an array of counters. */ - -#define VALUE_TYPE INT64 -#define KEY1_TYPE INT64 -#include "pmap-gen.c" - -#include "map.c" - -#define check(map,num) \ - { \ - int size = _stp_pmap_size(map); \ - if (size != num) \ - printf("ERROR at line %d: expected size %d and got %d instead.\n", __LINE__, num, size); \ - } - -int main () -{ - PMAP map = _stp_pmap_new_ii(8); - int64_t x; - - check(map,0); - - /* put some data in. _processor_number is a global hack that allows */ - /* us to set the current emulated cpu number for our userspace tests. */ - /* Note that we set values based on the cpu number just to show that */ - /* different values are stored in each cpu */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - _stp_pmap_add_ii(map, 1, _processor_number); - _stp_pmap_add_ii(map, 2, 10 *_processor_number + 1); - _stp_pmap_add_ii(map, 3, _processor_number * _processor_number); - _stp_pmap_add_ii(map, 4, 1); - } - _processor_number = 0; - - check(map,4*NR_CPUS-2); - - _stp_pmap_add_ii(map, 1, 1); - _stp_pmap_add_ii(map, 3, 1); - check(map,4*NR_CPUS); - - _stp_pmap_add_ii(map, 5, 100); - check(map,4*NR_CPUS+1); - - _processor_number = 1; - _stp_pmap_add_ii(map, 5, 100); - check(map,4*NR_CPUS+2); - - _stp_pmap_set_ii(map, 5, 0); - check(map,4*NR_CPUS+1); - - _processor_number = 0; - _stp_pmap_set_ii(map, 5, 0); - check(map,4*NR_CPUS); - - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - _stp_pmap_set_ii(map, 1, 0); - _stp_pmap_set_ii(map, 2, 0); - _stp_pmap_set_ii(map, 3, 0); - _stp_pmap_set_ii(map, 4, 0); - } - _processor_number = 0; - check(map,0); - - _stp_pmap_del (map); - return 0; -} - diff --git a/runtime/tests/string/Makefile b/runtime/tests/string/Makefile deleted file mode 100644 index c396c132..00000000 --- a/runtime/tests/string/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -default: tests - -tests: - tclsh all.tcl - diff --git a/runtime/tests/string/all.tcl b/runtime/tests/string/all.tcl deleted file mode 100644 index 23757202..00000000 --- a/runtime/tests/string/all.tcl +++ /dev/null @@ -1,4 +0,0 @@ -package require tcltest -namespace import -force tcltest::* -tcltest::testsDirectory [file dir [info script]] -tcltest::runAllTests diff --git a/runtime/tests/string/print_cstr.c b/runtime/tests/string/print_cstr.c deleted file mode 100644 index 2de0f592..00000000 --- a/runtime/tests/string/print_cstr.c +++ /dev/null @@ -1,56 +0,0 @@ -/* test of _stp_print_cstr() */ - -/* use very small buffer size for testing */ -#define STP_PRINT_BUF_LEN 20 -#include "runtime.h" - -int main () -{ - /* can we see output? */ - _stp_print_cstr("ABCDE\n"); - _stp_print_flush(); - - - /* overflow */ - _stp_print_cstr("1234567890123456789012345\n"); - _stp_print_cstr("XYZZY\n"); - _stp_print_flush(); - - /* small string then overflow string */ - _stp_print_cstr("XYZZY\n"); - _stp_print_cstr("1234567890123456789012345"); - _stp_print_cstr("\n"); - _stp_print_flush(); - - /* two small string that overflow */ - _stp_print_cstr("abcdefghij"); - _stp_print_cstr("1234567890"); - _stp_print_cstr("\n"); - _stp_print_flush(); - - /* two small string that overflow */ - _stp_print_cstr("abcdefghij"); - _stp_print_cstr("1234567890X"); - _stp_print_cstr("\n"); - _stp_print_flush(); - - _stp_print_cstr("12345\n"); - _stp_print_cstr("67890\n"); - _stp_print_cstr("abcde\n"); - _stp_print_flush(); - _stp_print_flush(); - _stp_print_cstr("12345"); - _stp_print_cstr("67890"); - _stp_print_cstr("abcde"); - _stp_print_cstr("fghij"); - _stp_print_cstr("\n"); - _stp_print_flush(); - - /* null string */ - _stp_print_cstr(""); - _stp_print_flush(); - _stp_print_cstr(""); - _stp_print_cstr("Q\n"); - _stp_print_flush(); - return 0; -} diff --git a/runtime/tests/string/printf_A.c b/runtime/tests/string/printf_A.c deleted file mode 100644 index e6c1a93f..00000000 --- a/runtime/tests/string/printf_A.c +++ /dev/null @@ -1,56 +0,0 @@ -/* basic printf tests */ - -/* use very small buffer size for testing */ -#define STP_PRINT_BUF_LEN 20 -#include "runtime.h" - -int main () -{ - /* can we see output? */ - _stp_printf("ABCDE\n"); - _stp_print_flush(); - - - /* overflow */ - _stp_printf("1234567890123456789012345\n"); - _stp_printf("XYZZY\n"); - _stp_print_flush(); - - /* small string then overflow string */ - _stp_printf("XYZZY\n"); - _stp_printf("1234567890123456789012345"); - _stp_printf("\n"); - _stp_print_flush(); - - /* two small string that overflow */ - _stp_printf("abcdefghij"); - _stp_printf("1234567890"); - _stp_printf("\n"); - _stp_print_flush(); - - /* two small string that overflow */ - _stp_printf("abcdefghij"); - _stp_printf("1234567890X"); - _stp_printf("\n"); - _stp_print_flush(); - - _stp_printf("12345\n"); - _stp_printf("67890\n"); - _stp_printf("abcde\n"); - _stp_print_flush(); - _stp_print_flush(); - _stp_printf("12345"); - _stp_printf("67890"); - _stp_printf("abcde"); - _stp_printf("fghij"); - _stp_printf("\n"); - _stp_print_flush(); - - /* null string */ - _stp_printf(""); - _stp_print_flush(); - _stp_printf(""); - _stp_printf("Q\n"); - _stp_print_flush(); - return 0; -} diff --git a/runtime/tests/string/printf_B.c b/runtime/tests/string/printf_B.c deleted file mode 100644 index b9bbe170..00000000 --- a/runtime/tests/string/printf_B.c +++ /dev/null @@ -1,37 +0,0 @@ -/* more printf tests */ - -/* use very small buffer size for testing */ -#define STP_PRINT_BUF_LEN 20 -#include "runtime.h" - -#define LLONG_MAX 9223372036854775807LL -#define LLONG_MIN (-LLONG_MAX - 1LL) - - -int main () -{ - int i; - - /* a couple of loops showing continuous output */ - for (i = 0; i < 20; i++) - _stp_sprintf(_stp_stdout, "i=%d ", i); - _stp_printf("\n"); - _stp_print_flush(); - - for (i = 0; i < 5; i++) - _stp_printf("[%d %d %d] ", i, i*i, i*i*i); - _stp_printf("\n"); - _stp_print_flush(); - - int64_t x,y; - x = LLONG_MAX; - y = LLONG_MIN; - - _stp_printf("%lld ",x); - _stp_printf("(%llx) ", x); - _stp_printf("%lld ",y); - _stp_printf("(%llx) ", y); - _stp_printf("\n"); - _stp_print_flush(); - return 0; -} diff --git a/runtime/tests/string/string.test b/runtime/tests/string/string.test deleted file mode 100644 index 348b6b1f..00000000 --- a/runtime/tests/string/string.test +++ /dev/null @@ -1,89 +0,0 @@ -package require tcltest -namespace import -force tcltest::* - -cd $tcltest::testsDirectory - -set CFLAGS "-Os" -set KPATH "/lib/modules/[exec uname -r]/build/include" -set MPATH "/lib/modules/[exec uname -r]/build/include/asm/mach-default" -set PATH "../../user" - -test printf_A {Basic printf test} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test printf_A.c -} -body { - exec ./test -} -result {ABCDE -12345678901234567890XYZZY -XYZZY -12345678901234567890 -abcdefghij1234567890 -abcdefghij1234567890X -12345 -67890 -abcde -1234567890abcdefghij -Q} - -test printf_B {More printf test} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test printf_B.c -} -body { - exec ./test -} -result {i=0 i=1 i=2 i=3 i=4 i=5 i=6 i=7 i=8 i=9 i=10 i=11 i=12 i=13 i=14 i=15 i=16 i=17 i=18 i=19 -[0 0 0] [1 1 1] [2 4 8] [3 9 27] [4 16 64] -9223372036854775807 (7fffffffffffffff) -9223372036854775808(8000000000000000) } - -test print_cstr {Test of _stp_print_cstr()} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test print_cstr.c -} -body { - exec ./test -} -result {ABCDE -12345678901234567890XYZZY -XYZZY -12345678901234567890 -abcdefghij1234567890 -abcdefghij1234567890X -12345 -67890 -abcde -1234567890abcdefghij -Q} - -test string1 {Basic String test} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test string1.c -} -body { - exec ./test -} -result {Hello worldRed HatIntelIBM -Hello world / Red Hat / Intel / IBM / -Red Hat Inc. -Hello world Red Hat -IntelIBM} - -test string2 {More String tests} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test string2.c -} -body { - exec ./test -} -result {ABCDE -1234567890123456789 -XYZZY -1234567890123 -abcdefghij123456789 -abcdefghij123456789 -12345 -67890 -abcde -1234567890abcdefghi -Q} -test string3 {Even More String tests} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test string3.c -} -body { - exec ./test -} -result {1234567890abcABCDEvwxyz -abcde -1234567890abcde -1234567890abcdeABCD -1234567890abcdeABCD -ABCDEvwxyz} - -exec rm test - -cleanupTests diff --git a/runtime/tests/string/string1.c b/runtime/tests/string/string1.c deleted file mode 100644 index 48773e5f..00000000 --- a/runtime/tests/string/string1.c +++ /dev/null @@ -1,44 +0,0 @@ -/* test of Strings */ - -/* use very small buffer size for testing */ -#define STP_PRINT_BUF_LEN 20 -#define STP_NUM_STRINGS 4 -#include "runtime.h" - -int main () -{ - String str[4]; - int i; - - for (i = 0; i < 4; i++) - str[i] = _stp_string_init (i); - - _stp_sprintf(str[0], "Hello world"); - _stp_sprintf(str[1], "Red Hat"); - _stp_sprintf(str[2], "Intel"); - _stp_sprintf(str[3], "IBM"); - - for (i = 0; i < 4; i++) - _stp_print(str[i]); - _stp_print_cstr("\n"); - - for (i = 0; i < 4; i++) { - _stp_print(str[i]); - _stp_print(" / "); - } - _stp_print_cstr("\n"); - - _stp_string_cat_cstr (str[1], " Inc."); - _stp_print(str[1]); - _stp_print("\n"); - - _stp_string_cat_cstr (str[0], " "); - _stp_string_cat_string (str[0], str[1]); - _stp_print(str[0]); - _stp_print("\n"); - - _stp_sprintf(str[2], "%s\n", _stp_string_ptr(str[3])); - _stp_print(str[2]); - _stp_print_flush(); - return 0; -} diff --git a/runtime/tests/string/string2.c b/runtime/tests/string/string2.c deleted file mode 100644 index ccf3997a..00000000 --- a/runtime/tests/string/string2.c +++ /dev/null @@ -1,68 +0,0 @@ -/* test of Strings */ - -/* use very small buffer size for testing */ -#define STP_STRING_SIZE 20 -#define STP_NUM_STRINGS 1 -#include "runtime.h" - -int main () -{ - String str = _stp_string_init (0); - - /* can we see output? */ - _stp_sprintf(str, "ABCDE\n"); - _stp_print(str); - - - /* overflow */ - str = _stp_string_init (0); - _stp_sprintf(str, "1234567890123456789012345\n"); - _stp_sprintf(str, "XYZZY\n"); - _stp_print(str); - _stp_printf("\n"); - - /* small string then overflow string */ - str = _stp_string_init (0); - _stp_sprintf(str,"XYZZY\n"); - _stp_sprintf(str,"1234567890123456789012345"); - _stp_print(str); - _stp_printf("\n"); - - /* two small string that overflow */ - str = _stp_string_init (0); - _stp_sprintf(str,"abcdefghij"); - _stp_sprintf(str,"123456789"); - _stp_print(str); - _stp_printf("\n"); - - /* two small string that overflow */ - str = _stp_string_init (0); - _stp_sprintf(str,"abcdefghij"); - _stp_sprintf(str,"1234567890X"); - _stp_print(str); - _stp_printf("\n"); - - str = _stp_string_init (0); - _stp_sprintf(str,"12345\n"); - _stp_sprintf(str,"67890\n"); - _stp_sprintf(str,"abcde\n"); - _stp_print(str); - - str = _stp_string_init (0); - _stp_sprintf(str,"12345"); - _stp_sprintf(str,"67890"); - _stp_sprintf(str,"abcde"); - _stp_sprintf(str,"fghij"); - _stp_print(str); - _stp_printf("\n"); - - /* null string */ - str = _stp_string_init (0); - _stp_sprintf(str,""); - _stp_sprintf(str,""); - _stp_sprintf(str,"Q\n"); - _stp_print(str); - - _stp_print_flush(); - return 0; -} diff --git a/runtime/tests/string/string3.c b/runtime/tests/string/string3.c deleted file mode 100644 index 3982a8e1..00000000 --- a/runtime/tests/string/string3.c +++ /dev/null @@ -1,45 +0,0 @@ -/* test of Strings */ - -/* use very small buffer size for testing */ -#define STP_STRING_SIZE 20 -#define STP_NUM_STRINGS 4 -#include "runtime.h" - -int main () -{ - String str[4]; - int i; - - for (i = 0; i < 4; i++) - str[i] = _stp_string_init (i); - - _stp_string_cat(str[0], "1234567890"); - _stp_string_cat(str[1], "abc"); - _stp_string_cat(str[2], "ABCDE"); - _stp_string_cat(str[3], "vwxyz"); - - for (i = 0; i < 4; i++) - _stp_print(str[i]); - _stp_print("\n"); - - _stp_string_cat (str[1], "de"); - _stp_print(str[1]); - _stp_print("\n"); - - _stp_string_cat(str[0], str[1]); - _stp_print(str[0]); - _stp_print("\n"); - - _stp_string_cat(str[0], str[2]); - _stp_print(str[0]); - _stp_print("\n"); - - _stp_string_cat(str[0], str[2]); - _stp_print(str[0]); - _stp_print("\n"); - - _stp_sprintf(str[2], "%s\n", _stp_string_ptr(str[3])); - _stp_print(str[2]); - _stp_print_flush(); - return 0; -} |