Permalink
Browse files

version information added to server and C/C++ probe

  • Loading branch information...
dcieslak committed Nov 28, 2015
1 parent 1309419 commit fc6f8cfbec4cb1124c237bdfef4b4d2bcf7860c9
Showing with 82 additions and 14 deletions.
  1. +2 −0 .gitignore
  2. +5 −0 Makefile
  3. +2 −0 doc/Makefile
  4. +44 −0 doc/rtn-manual.md
  5. +1 −0 src/probes/c/Makefile
  6. +7 −1 src/probes/c/randomtest-probe.c
  7. +21 −13 src/server/randomtest-server.php
View
@@ -7,3 +7,5 @@ doc/diagrams/*.png
*.exe
local.mak
files.lst
doc/*.html
View
@@ -1,3 +1,5 @@
.PHONY: doc
default: build
build:
@@ -11,6 +13,9 @@ test: src/server/var
make -C src/probes/java test
wget -qO - $$RANDOMTEST_URL
doc:
make -C doc
src/server/var:
mkdir src/server/var
# PHP process (typically www-data) acess granted
View
@@ -0,0 +1,2 @@
all:
markdown rtn-manual.md > rtn-manual.html
View
@@ -0,0 +1,44 @@
RandomTest.net
==============
Building
--------
The following build commands are supported:
- make: builds Java and C/C++ probes
- make doc: builds HTML documentation in doc subdirectory
- make test: runs tests of the software (some special setup might be needed,
though)
randomtest-server.php
---------------------
This is a PHP script that has the following duties:
- collects crash reports from devices
- **?stacktrace=...&version=...** - adds stacktrace to the database
(multiple reports are merged into one), version information is preserved
there
- allows to reset it's state
- **?reset=<PASSWORD>** - request database reset, PASSWORD is embedded into
the script (to restrict state change operation to a trusted list of
persons / programs)
- presents aggregated report of the crashes
- no arguments passed
randomtest-probe.c
------------------
This is a probe for C, C++ family of languages. The following environment
variables are recognized:
- RANDOMTEST\_FILE: the file where crash stacktraces must be appended,
optional
- RANDOMTEST\_URL: the URL of randomtest-server.php where crash reports
should be sent
- RANDOMTEST\_VERSION: the version of the software (string) that is currently
tested, it's used in the stacktrace aggretor to collect version
information, optional (if not set: ampty version is used)
View
@@ -10,6 +10,7 @@ test1.exe: test1.cpp
$(CXX) -rdynamic -Wall -Werror --pedantic-errors test1.cpp -o test1.exe
test:
echo RANDOMTEST_URL=$(RANDOMTEST_URL)
LD_PRELOAD=./$(PROBE_NAME).so ./test1.exe || true
clean:
@@ -193,6 +193,8 @@ void record_event(const char *source) {
const char *fileNameToSave = getenv("RANDOMTEST_FILE");
const char *url = getenv("RANDOMTEST_URL");
const char *version = getenv("RANDOMTEST_VERSION");
char rawStacktrace[BUFSIZE];
char encodedStacktrace[BUFSIZE];
@@ -214,7 +216,11 @@ void record_event(const char *source) {
return;
}
url_encode("stacktrace=", rawStacktrace, encodedStacktrace, encodedStacktrace + BUFSIZE);
char* buf_ptr = url_encode("stacktrace=", rawStacktrace, encodedStacktrace, encodedStacktrace + BUFSIZE);
*buf_ptr++ = '&';
if (version) {
buf_ptr = url_encode("version=", version, buf_ptr, encodedStacktrace + BUFSIZE);
}
CURL* handle = curl_easy_init();
curl_easy_setopt(handle, CURLOPT_URL, url);
@@ -1,8 +1,7 @@
#!/usr/bin/php-cgi
<?php
$DATABASE_FILE = "var/randomtest.db";
$db = dba_open($DATABASE_FILE, "c");
$db_counters = dba_open("var/counters.db", "c");
$db_versions = dba_open("var/versions.db", "c");
if (isset($_POST['stacktrace'])) {
header('Content-type: text/plain');
@@ -11,40 +10,49 @@
$stacktrace = $_POST['stacktrace'];
echo $stacktrace;
if (dba_exists($stacktrace, $db)) {
$counter = dba_fetch($stacktrace, $db) + 1;
$version = $_POST['version'];
echo $version;
if (dba_exists($stacktrace, $db_counters)) {
$counter = dba_fetch($stacktrace, $db_counters) + 1;
$versions = dba_fetch($stacktrace, $db_versions);
if (strstr($versions, $version) === false) {
$versions = $versions . " " . $version;
}
}
else {
$counter = 1;
$versions = $version;
}
dba_replace($stacktrace, $counter, $db);
dba_replace($stacktrace, $counter, $db_counters);
dba_replace($stacktrace, $versions, $db_versions);
}
else if (isset($_GET['count'])) {
// Shows total counter of all recorded stacktraces including duplicates
// Purpose: for local tests of probes
header('Content-type: text/plain');
$counter = 0;
for($stacktrace = dba_firstkey($db); $stacktrace != false; $stacktrace = dba_nextkey($db)) {
$counter += dba_fetch($stacktrace, $db);
for($stacktrace = dba_firstkey($db_counters); $stacktrace != false; $stacktrace = dba_nextkey($db_counters)) {
$counter += dba_fetch($stacktrace, $db_counters);
}
echo "$counter\n";
}
else {
header('Content-type: text/plain');
echo "RandomTest.net report\n\n";
for($stacktrace = dba_firstkey($db); $stacktrace != false; $stacktrace = dba_nextkey($db)) {
$counter = dba_fetch($stacktrace, $db);
for($stacktrace = dba_firstkey($db_counters); $stacktrace != false; $stacktrace = dba_nextkey($db_counters)) {
$counter = dba_fetch($stacktrace, $db_counters);
$arr[$stacktrace] = $counter;
}
// sort array by counter, keys=stacktraces left
arsort($arr);
foreach ($arr as $stacktrace => $counter) {
$s = rtrim($stacktrace);
echo "event counter: $counter\n$s\n\n";
$versions = dba_fetch($stacktrace, $db_versions);
echo "event counter: $counter\nversions: $versions\n$s\n\n";
}
}
dba_close($db);
dba_close($db_counters);
?>

0 comments on commit fc6f8cf

Please sign in to comment.