Compare commits

..
18 Commits
Author SHA1 Message Date
Alex Jaramillo c3b8d81b6d configure.ac: bump version
Increase the version to 2.3.5 to release fix for missing records in
journal and preempt klogscanner service start inside containers.

Signed-off-by: Alex Jaramillo <alex.v.jaramillo@intel.com>
2020-02-24 21:37:06 +00:00
Alex Jaramillo f4f012af7b fix first record missing from journal
This change fixes the condition when the first record after telempostd
starts is not inserted in the telemetry journal.

Notice! there is a change in the logic, while previously records
where inserted to juornal as soon the record was processed. After this
change records will be inserted in the journal only when successfully
delivered or record_server_delivery_enabled is set to false.
2020-02-24 13:27:32 -08:00
Thiago Macieira 9db4e1d8c9 Don't try to start the klogscanner service inside a container
We can't access the klog.

● klogscanner.service - Telemetrics Kernel Log Scanner
     Loaded: loaded (/usr/lib/systemd/system/klogscanner.service; disabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Fri 2020-01-31 10:44:58 PST; 8min ago
    Process: 21 ExecStart=/usr/bin/klogscanner (code=exited, status=1/FAILURE)
   Main PID: 21 (code=exited, status=1/FAILURE)

Jan 31 10:44:58 <MACHINENAME> systemd[1]: Started Telemetrics Kernel Log Scanner.
Jan 31 10:44:58 <MACHINENAME> klogscanner[21]: ERROR: Cannot read size of kernel ring buffer: Operation not permitted
Jan 31 10:44:58 <MACHINENAME> systemd[1]: klogscanner.service: Main process exited, code=exited, status=1/FAILURE
Jan 31 10:44:58 <MACHINENAME> systemd[1]: klogscanner.service: Failed with result 'exit-code'.
2020-02-05 10:06:08 -08:00
Alex Jaramillo a0efa230b7 configure.ac: bump version
Increase the version to 2.3.4 to release CI configuration changes,
memory leaks fixes, and crash probe frame counter fix.

Signed-off-by: Alex Jaramillo <alex.v.jaramillo@intel.com>
2020-01-30 21:58:59 +00:00
Juro Bystricky f14d6ff4c5 crash_probe.c: process_corefile: reset frame counter
process_corefile may be called twice due to retry logic.
Make sure frame_counter is initialized each time.

Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
2020-01-30 13:11:26 -08:00
Alex Jaramillo b61b152cb0 replace travis badge for github workflows 2020-01-27 11:05:46 -08:00
Alex Jaramillo ee25d1568d random shift to hprobe timer 2020-01-24 10:47:55 -08:00
avjarami 622fcfca10 pr comments and actions update 2020-01-22 16:08:15 -08:00
avjarami 33609c5607 update CI configuration 2020-01-22 16:08:15 -08:00
avjarami 8ebc882955 fix potential leaks 2020-01-22 16:08:15 -08:00
avjarami d30eb663b3 fixing memory leaks in tests 2020-01-22 16:08:15 -08:00
avjarami 885e325e1e valgrind check for tests 2020-01-22 16:08:15 -08:00
avjarami fffe18a96b Trigger verification on PR opening 2020-01-22 18:03:24 +00:00
Juro Bystricky d9925e1f96 configure.ac: bump version
Increase the version to 2.3.3 due to the fixed buffer
overrun in telemctl.c.

Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
2020-01-09 13:32:30 -08:00
Juro Bystricky c3ae907651 telemctl.c: fix buffer overflow
The function "concatargs" allocated a buffer for concatenated strings
that was 1 byte short of needed, not accounting for the terminating
NULL char.

Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
2020-01-09 08:53:42 -08:00
Juro Bystricky 8ca299314c configure.ac: bump version
Increase the version to 2.3.2 to reflect the fact that
bertprobe was entirely removed. The bertprobe functionality
was moved to klogscanner.

Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
2019-12-17 18:39:20 -08:00
Juro Bystricky 53d4c229a7 klog_scanner.c: truncate payload if needed
Payloads can exceed MAX_PAYLOAD_SIZE, in which case the probe
will fail to send any data to the backend server. This was observed
with BERT payloads, but other payload types can exceed the maximum
size as well.

This patch truncates the payload if needed. It is better to receive
a truncated report than none.

Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
2019-12-16 10:49:50 -08:00
Juro Bystricky 7a3082eb59 Merge BERT probe with klogscanner
New Linux kernels detect/interpret/display BERT errors in klog.
This makes bertprobe unnecessary, as all the information can
be simply grabbed from klog. This also removes the need to
encode the binary data into HEX/ASCII, so all the encoding
code can be removed as well, including the test suite.

The change was implemented by adding a new pattern for BERT
in the oops_parser.c with some additional minor changes.

Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
2019-12-13 15:16:20 -08:00
35 changed files with 547 additions and 768 deletions
+3 -1
View File
@@ -1,6 +1,6 @@
name: C/C++ CI
on: [push]
on: [push, pull_request]
jobs:
build:
@@ -25,5 +25,7 @@ jobs:
run: make -j8
- name: check
run: make check
- name: valgrind memcheck
run: make check-valgrind
- name: make distcheck
run: make distcheck
+1 -2
View File
@@ -35,11 +35,11 @@ build-aux/m4/ltversion.m4
/tags
telemprobd
telempostd
telemctl
autoscan.log
configure.scan
tprobe
hprobe
bertprobe
crashprobe
journalprobe
telem-record-gen
@@ -57,7 +57,6 @@ tests/check_config
tests/check_daemon
tests/check_journal
tests/check_libtelemetry
tests/check_ncb64
tests/check_postd
tests/check_probd
tests/check_probes
-35
View File
@@ -1,35 +0,0 @@
dist: trusty
compiler:
- gcc
os:
- linux
before_script:
./autogen.sh
language: c
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libcurl4-gnutls-dev
- valgrind
- autoconf
- automake
- check
- libelf-dev
- libdw-dev
install:
- wget https://github.com/libcheck/check/releases/download/0.12.0/check-0.12.0.tar.gz
- tar -xvf check-0.12.0.tar.gz
- pushd check-0.12.0 && ./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu && make -j48 && sudo make install && popd
script:
- ./configure && make && make check
after_failure: cat test-suite.log
+1 -1
View File
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/clearlinux/telemetrics-client.svg?branch=master)](https://travis-ci.org/clearlinux/telemetrics-client)
![](https://github.com/clearlinux/telemetrics-client/workflows/C%2FC++%20CI/badge.svg)
Telemetrics-client
==================
+239
View File
@@ -0,0 +1,239 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_valgrind_check.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_VALGRIND_DFLT(memcheck|helgrind|drd|sgcheck, on|off)
# AX_VALGRIND_CHECK()
#
# DESCRIPTION
#
# AX_VALGRIND_CHECK checks whether Valgrind is present and, if so, allows
# running `make check` under a variety of Valgrind tools to check for
# memory and threading errors.
#
# Defines VALGRIND_CHECK_RULES which should be substituted in your
# Makefile; and $enable_valgrind which can be used in subsequent configure
# output. VALGRIND_ENABLED is defined and substituted, and corresponds to
# the value of the --enable-valgrind option, which defaults to being
# enabled if Valgrind is installed and disabled otherwise. Individual
# Valgrind tools can be disabled via --disable-valgrind-<tool>, the
# default is configurable via the AX_VALGRIND_DFLT command or is to use
# all commands not disabled via AX_VALGRIND_DFLT. All AX_VALGRIND_DFLT
# calls must be made before the call to AX_VALGRIND_CHECK.
#
# If unit tests are written using a shell script and automake's
# LOG_COMPILER system, the $(VALGRIND) variable can be used within the
# shell scripts to enable Valgrind, as described here:
#
# https://www.gnu.org/software/gnulib/manual/html_node/Running-self_002dtests-under-valgrind.html
#
# Usage example:
#
# configure.ac:
#
# AX_VALGRIND_DFLT([sgcheck], [off])
# AX_VALGRIND_CHECK
#
# in each Makefile.am with tests:
#
# @VALGRIND_CHECK_RULES@
# VALGRIND_SUPPRESSIONS_FILES = my-project.supp
# EXTRA_DIST = my-project.supp
#
# This results in a "check-valgrind" rule being added. Running `make
# check-valgrind` in that directory will recursively run the module's test
# suite (`make check`) once for each of the available Valgrind tools (out
# of memcheck, helgrind and drd) while the sgcheck will be skipped unless
# enabled again on the commandline with --enable-valgrind-sgcheck. The
# results for each check will be output to test-suite-$toolname.log. The
# target will succeed if there are zero errors and fail otherwise.
#
# Alternatively, a "check-valgrind-$TOOL" rule will be added, for $TOOL in
# memcheck, helgrind, drd and sgcheck. These are useful because often only
# some of those tools can be ran cleanly on a codebase.
#
# The macro supports running with and without libtool.
#
# LICENSE
#
# Copyright (c) 2014, 2015, 2016 Philip Withnall <philip.withnall@collabora.co.uk>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 17
dnl Configured tools
m4_define([valgrind_tool_list], [[memcheck], [helgrind], [drd], [sgcheck]])
m4_set_add_all([valgrind_exp_tool_set], [sgcheck])
m4_foreach([vgtool], [valgrind_tool_list],
[m4_define([en_dflt_valgrind_]vgtool, [on])])
AC_DEFUN([AX_VALGRIND_DFLT],[
m4_define([en_dflt_valgrind_$1], [$2])
])dnl
AM_EXTRA_RECURSIVE_TARGETS([check-valgrind])
m4_foreach([vgtool], [valgrind_tool_list],
[AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)])
AC_DEFUN([AX_VALGRIND_CHECK],[
dnl Check for --enable-valgrind
AC_ARG_ENABLE([valgrind],
[AS_HELP_STRING([--enable-valgrind], [Whether to enable Valgrind on the unit tests])],
[enable_valgrind=$enableval],[enable_valgrind=])
AS_IF([test "$enable_valgrind" != "no"],[
# Check for Valgrind.
AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind])
AS_IF([test "$VALGRIND" = ""],[
AS_IF([test "$enable_valgrind" = "yes"],[
AC_MSG_ERROR([Could not find valgrind; either install it or reconfigure with --disable-valgrind])
],[
enable_valgrind=no
])
],[
enable_valgrind=yes
])
])
AM_CONDITIONAL([VALGRIND_ENABLED],[test "$enable_valgrind" = "yes"])
AC_SUBST([VALGRIND_ENABLED],[$enable_valgrind])
# Check for Valgrind tools we care about.
[valgrind_enabled_tools=]
m4_foreach([vgtool],[valgrind_tool_list],[
AC_ARG_ENABLE([valgrind-]vgtool,
m4_if(m4_defn([en_dflt_valgrind_]vgtool),[off],dnl
[AS_HELP_STRING([--enable-valgrind-]vgtool, [Whether to use ]vgtool[ during the Valgrind tests])],dnl
[AS_HELP_STRING([--disable-valgrind-]vgtool, [Whether to skip ]vgtool[ during the Valgrind tests])]),
[enable_valgrind_]vgtool[=$enableval],
[enable_valgrind_]vgtool[=])
AS_IF([test "$enable_valgrind" = "no"],[
enable_valgrind_]vgtool[=no],
[test "$enable_valgrind_]vgtool[" ]dnl
m4_if(m4_defn([en_dflt_valgrind_]vgtool), [off], [= "yes"], [!= "no"]),[
AC_CACHE_CHECK([for Valgrind tool ]vgtool,
[ax_cv_valgrind_tool_]vgtool,[
ax_cv_valgrind_tool_]vgtool[=no
m4_set_contains([valgrind_exp_tool_set],vgtool,
[m4_define([vgtoolx],[exp-]vgtool)],
[m4_define([vgtoolx],vgtool)])
AS_IF([`$VALGRIND --tool=]vgtoolx[ --help >/dev/null 2>&1`],[
ax_cv_valgrind_tool_]vgtool[=yes
])
])
AS_IF([test "$ax_cv_valgrind_tool_]vgtool[" = "no"],[
AS_IF([test "$enable_valgrind_]vgtool[" = "yes"],[
AC_MSG_ERROR([Valgrind does not support ]vgtool[; reconfigure with --disable-valgrind-]vgtool)
],[
enable_valgrind_]vgtool[=no
])
],[
enable_valgrind_]vgtool[=yes
])
])
AS_IF([test "$enable_valgrind_]vgtool[" = "yes"],[
valgrind_enabled_tools="$valgrind_enabled_tools ]m4_bpatsubst(vgtool,[^exp-])["
])
AC_SUBST([ENABLE_VALGRIND_]vgtool,[$enable_valgrind_]vgtool)
])
AC_SUBST([valgrind_tools],["]m4_join([ ], valgrind_tool_list)["])
AC_SUBST([valgrind_enabled_tools],[$valgrind_enabled_tools])
[VALGRIND_CHECK_RULES='
# Valgrind check
#
# Optional:
# - VALGRIND_SUPPRESSIONS_FILES: Space-separated list of Valgrind suppressions
# files to load. (Default: empty)
# - VALGRIND_FLAGS: General flags to pass to all Valgrind tools.
# (Default: --num-callers=30)
# - VALGRIND_$toolname_FLAGS: Flags to pass to Valgrind $toolname (one of:
# memcheck, helgrind, drd, sgcheck). (Default: various)
# Optional variables
VALGRIND_SUPPRESSIONS ?= $(addprefix --suppressions=,$(VALGRIND_SUPPRESSIONS_FILES))
VALGRIND_FLAGS ?= --num-callers=30
VALGRIND_memcheck_FLAGS ?= --leak-check=full --show-reachable=no
VALGRIND_helgrind_FLAGS ?= --history-level=approx
VALGRIND_drd_FLAGS ?=
VALGRIND_sgcheck_FLAGS ?=
# Internal use
valgrind_log_files = $(addprefix test-suite-,$(addsuffix .log,$(valgrind_tools)))
valgrind_memcheck_flags = --tool=memcheck $(VALGRIND_memcheck_FLAGS)
valgrind_helgrind_flags = --tool=helgrind $(VALGRIND_helgrind_FLAGS)
valgrind_drd_flags = --tool=drd $(VALGRIND_drd_FLAGS)
valgrind_sgcheck_flags = --tool=exp-sgcheck $(VALGRIND_sgcheck_FLAGS)
valgrind_quiet = $(valgrind_quiet_$(V))
valgrind_quiet_ = $(valgrind_quiet_$(AM_DEFAULT_VERBOSITY))
valgrind_quiet_0 = --quiet
valgrind_v_use = $(valgrind_v_use_$(V))
valgrind_v_use_ = $(valgrind_v_use_$(AM_DEFAULT_VERBOSITY))
valgrind_v_use_0 = @echo " USE " $(patsubst check-valgrind-%-am,%,$''@):;
# Support running with and without libtool.
ifneq ($(LIBTOOL),)
valgrind_lt = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=execute
else
valgrind_lt =
endif
# Use recursive makes in order to ignore errors during check
check-valgrind-am:
ifeq ($(VALGRIND_ENABLED),yes)
$(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) -k \
$(foreach tool, $(valgrind_enabled_tools), check-valgrind-$(tool))
else
@echo "Need to reconfigure with --enable-valgrind"
endif
# Valgrind running
VALGRIND_TESTS_ENVIRONMENT = \
$(TESTS_ENVIRONMENT) \
env VALGRIND=$(VALGRIND) \
G_SLICE=always-malloc,debug-blocks \
G_DEBUG=fatal-warnings,fatal-criticals,gc-friendly
VALGRIND_LOG_COMPILER = \
$(valgrind_lt) \
$(VALGRIND) $(VALGRIND_SUPPRESSIONS) --error-exitcode=1 $(VALGRIND_FLAGS)
define valgrind_tool_rule
check-valgrind-$(1)-am:
ifeq ($$(VALGRIND_ENABLED)-$$(ENABLE_VALGRIND_$(1)),yes-yes)
ifneq ($$(TESTS),)
$$(valgrind_v_use)$$(MAKE) check-TESTS \
TESTS_ENVIRONMENT="$$(VALGRIND_TESTS_ENVIRONMENT)" \
LOG_COMPILER="$$(VALGRIND_LOG_COMPILER)" \
LOG_FLAGS="$$(valgrind_$(1)_flags)" \
TEST_SUITE_LOG=test-suite-$(1).log
endif
else ifeq ($$(VALGRIND_ENABLED),yes)
@echo "Need to reconfigure with --enable-valgrind-$(1)"
else
@echo "Need to reconfigure with --enable-valgrind"
endif
endef
$(foreach tool,$(valgrind_tools),$(eval $(call valgrind_tool_rule,$(tool))))
A''M_DISTCHECK_CONFIGURE_FLAGS ?=
A''M_DISTCHECK_CONFIGURE_FLAGS += --disable-valgrind
MOSTLYCLEANFILES ?=
MOSTLYCLEANFILES += $(valgrind_log_files)
.PHONY: check-valgrind $(add-prefix check-valgrind-,$(valgrind_tools))
']
AC_SUBST([VALGRIND_CHECK_RULES])
m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([VALGRIND_CHECK_RULES])])
])
+11 -1
View File
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([telemetrics-client], [2.3.1], [https://clearlinux.org/])
AC_INIT([telemetrics-client], [2.3.5], [https://clearlinux.org/])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([1.14 -Wall -Werror -Wno-extra-portability foreign subdir-objects])
AM_SILENT_RULES([yes])
@@ -20,6 +20,14 @@ AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
# Valgrind check
AX_VALGRIND_DFLT(memcheck, on)
AX_VALGRIND_DFLT(helgrind, off)
AX_VALGRIND_DFLT(drd, off)
AX_VALGRIND_DFLT(sgcheck, off)
AX_VALGRIND_CHECK
# Checks for libraries.
# check >= 0.9.12 is required for TAP output
@@ -171,4 +179,6 @@ systemconfdir: $confpath
socketdir: $socketpath
loglevel: $loglevel
logtype: $logtype
valgrind: $enable_valgrind
])
+20
View File
@@ -152,6 +152,18 @@ bool set_default_config_values(struct configuration *config)
return true;
}
/* Needed for unit testing */
void free_config_struct(struct configuration *config)
{
if (keyfile != NULL) {
nc_hashmap_free(keyfile);
}
for (int i = 0; i < CONF_STR_MAX; i++) {
free(config->strValues[i]);
}
}
bool read_config_from_file(char *config_file, struct configuration *config)
{
if (keyfile != NULL) {
@@ -275,6 +287,14 @@ void free_configuration(void)
}
}
/* Needed for unit testing */
void free_config_file(void)
{
if (config_file) {
free(config_file);
}
}
const char *server_addr_config()
{
initialize_config();
-13
View File
@@ -1,13 +0,0 @@
[Unit]
Description=Telemetrics BERT Probe
Requires=telemprobd.socket
After=telemprobd.socket
ConditionPathExists=/etc/telemetrics/opt-in
ConditionPathExists=/sys/firmware/acpi/tables/data/BERT
[Service]
ExecStart=@bindir@/bertprobe
User=root
[Install]
WantedBy=multi-user.target
+1
View File
@@ -5,6 +5,7 @@ ConditionPathExists=/etc/telemetrics/opt-in
[Timer]
OnCalendar=daily
AccuracySec=12h
RandomizedDelaySec=21600
Persistent=true
[Install]
+1
View File
@@ -1,5 +1,6 @@
[Unit]
Description=Telemetrics Kernel Log Scanner
ConditionVirtualization=!container
Requires=telemprobd.socket
After=telemprobd.socket
-6
View File
@@ -16,7 +16,6 @@ EXTRA_DIST += \
%D%/example.2.conf \
%D%/hprobe.service.in \
%D%/hprobe.timer \
%D%/bert-probe.service.in \
%D%/journal-probe.service.in \
%D%/journal-probe-tail.service.in \
%D%/pstore-probe.service.in \
@@ -53,7 +52,6 @@ systemdunitdir = @SYSTEMD_UNITDIR@
systemdunit_DATA = \
%D%/hprobe.service \
%D%/hprobe.timer \
%D%/bert-probe.service \
%D%/journal-probe.service \
%D%/journal-probe-tail.service \
%D%/pstore-probe.service \
@@ -68,9 +66,6 @@ systemdunit_DATA = \
%D%/hprobe.service: %D%/hprobe.service.in
$(pathfix) < $< > $@
%D%/bert-probe.service: %D%/bert-probe.service.in
$(pathfix) < $< > $@
%D%/journal-probe.service: %D%/journal-probe.service.in
$(pathfix) < $< > $@
@@ -126,5 +121,4 @@ clean-local:
%D%/klogscanner.service \
%D%/pstore-clean.service \
%D%/hprobe.service \
%D%/bert-probe.service \
%D%/.dirstamp
-1
View File
@@ -101,7 +101,6 @@ noinst_LTLIBRARIES = %D%/libtelem-shared.la
%D%/configuration.c \
%D%/nica/inifile.c \
%D%/nica/hashmap.c \
%D%/nica/b64enc.c \
%D%/configuration.h \
%D%/common.c \
%D%/common.h
-154
View File
@@ -1,154 +0,0 @@
/*
* This file is part of libnica.
*
* Copyright © 2017 Intel Corporation
*
* libnica is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdint.h>
#include "b64enc.h"
#define B64_LINE_LEN 76
static int padding[] = {0, 2, 1, 0};
static char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/*
* base 64 encoding of 3 bytes to 4 printable characters
* (https://tools.ietf.org/html/rfc4648).
*
* i.e. (Reference: https://en.wikipedia.org/wiki/Base64)
*
* [ M ] [ a ] [ n ]
* bin 01001101 01100001 01101110
*
* b64 01001101 01100001 01101110 >> 18 & 0x3F -> 010011 -> ( 19 dec) T
* ------
*
* b64 01001101 01100001 01101110 >> 12 & 0x3F -> 010110 -> ( 22 dec) W
* -------
*
* b64 01001101 01100001 01101110 >> 6 & 0x3F -> 000101 -> ( 5 dec) F
* -------
*
* b64 01001101 01100001 01101110 >> 0 & 0x3F -> 101110 -> (117 dec) u
* ------
*
*/
static void b64_3b(char bin[3], char *out) {
uint32_t x = (((uint32_t) bin[0] << 16) & 0xFF0000) |
(((uint32_t) bin[1] << 8) & 0xFF00) |
(((uint32_t) bin[2]) & 0xFF);
out[3] = table[x & 0x3F];
out[2] = table[x >> 6 & 0x3F];
out[1] = table[x >> 12 & 0x3F];
out[0] = table[x >> 18 & 0x3F];
}
/*
* Provide padding to already initialized b64 output
*/
static void b64_padding(char *out, int pad_size) {
if (pad_size > 0) {
*out++ = '=';
}
if (pad_size > 1) {
*out++ = '=';
}
*out = '\0';
}
/*
* Encode file contents as b64 string
*/
int nc_b64enc_file(FILE *fh, char *buff, size_t buff_size) {
int ret_val = 1;
int out_count = 0;
int pad_size = 0;
char *buff_ptr = buff;
char bin[3] = {0, 0, 0};
size_t len = 0;
while ((len = fread(bin, 1, 3, fh)) > 0) {
b64_3b(bin, buff_ptr);
/*
Reset 2nd and 3rd bytes in case only one byte was read. If these
bytes are not clean b64 output will be corrupted with old bits.
*/
bin[1] = bin[2] = 0;
/*
Advance pointer to the next free position of the b64 encoded
buffer. This happens to be len + 1 (as longs as len >= 1 and len <= 3)
len = 1 byte -> b64 -> 2 bytes (or len + 1)
len = 2 bytes -> b64 -> 3 bytes (or len + 1)
len = 3 bytes -> b64 -> 4 bytes (or len + 1)
*/
buff_ptr += (len + 1);
/*
Line break every 76 characters
*/
out_count += (int) (len + 1);
if (out_count % B64_LINE_LEN == 0) {
*buff_ptr++ = '\n';
}
pad_size = padding[len];
/*
Check not to overflow buffer
buffer size <= b64 characters + padding length + null termination
*/
if (buff_size <= (size_t) (buff_ptr - buff) + (size_t) pad_size + 1) {
ret_val = 0;
goto end_b64_enc;
}
}
b64_padding(buff_ptr, pad_size);
end_b64_enc:
return ret_val;
}
int nc_b64enc_filename(const char *filename, char *buff, size_t buff_size) {
int ret = 0;
FILE *fh = NULL;
fh = fopen(filename, "rb");
if (fh == NULL) {
goto nc_b64_clean;
}
ret = nc_b64enc_file(fh, buff, buff_size);
nc_b64_clean:
if (fh) {
fclose(fh);
}
return ret;
}
/* vi: set ts=8 sw=8 sts=4 et tw=80 cino=(0: */
-42
View File
@@ -1,42 +0,0 @@
/*
* This file is part of libnica.
*
* Copyright © 2017 Intel Corporation
*
* libnica is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This is a chained base64 encode implementation.
*/
#pragma once
#define _GNU_SOURCE
#include "macros.h"
/*
* Encodes contents of file handler in base64
*
* @param fh File handler to encode as base64
* @param buff Output buffer where the base64 output should be written
* @param buff_size Size of the output buffer
*
* @returns 1 in success and 0 in failure
*/
_nica_public_ int nc_b64enc_file(FILE *fh, char *buff, size_t buff_size);
/*
* Encodes contents of file (filename) in base64
*
* @param filename File to encode as base64
* @param buff Output buffer where the base64 output should be written
* @param buff_size Size of the output buffer
*
* @returns 1 in success and 0 in failure
*/
_nica_public_ int nc_b64enc_filename(const char *filename, char *buff, size_t buff_size);
+1 -4
View File
@@ -2,9 +2,6 @@
The default probes provided along the telemetry client code are:
* bertprobe: this probe reports on the Boot Error Region Table if such
entry is found in ```/sys/firmware/acpi/tables/BERT```.
* crashprobe: This probe processes core dump files. It can be registered as
the kernel core file handler in /proc/sys/kernel/core_pattern.
@@ -15,7 +12,7 @@ The default probes provided along the telemetry client code are:
from failed services.
* klogscanner: a probe to collect 'oops messages' when the kernel detects a
problem.
problem. Also reports errors in the Boot Error Region Table if detected.
* pstoreprobe: probe to collect messages left on pstore filesystem.
-193
View File
@@ -1,193 +0,0 @@
/*
* This program is part of the Clear Linux Project
*
* Copyright 2018 Intel Corporation
*
* This program is free software; you can redistribute it and/or modify it under
* the terms and conditions of the GNU Lesser General Public License, as
* published by the Free Software Foundation; either version 2.1 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <getopt.h>
#include "common.h"
#include "telemetry.h"
#include "nica/b64enc.h"
#include "config.h"
#include "log.h"
static const char bert_record_file[] = "/sys/firmware/acpi/tables/data/BERT";
static const char telem_record_class[] = "org.clearlinux/bert/debug";
static uint32_t severity = 2;
static uint32_t payload_version = 1;
void print_usage(char *prog)
{
printf("%s: Usage\n", prog);
printf(" -f, --config_file Specify a configuration file other than default\n");
printf(" -h, --help Display this help message\n");
printf(" -V, --version Print the program version\n");
}
struct acpi_generic_error_data_entry {
uint8_t section_type[16];
uint32_t error_severity;
uint16_t revision;
uint8_t validation_bits;
uint8_t flags;
uint32_t error_data_length;
uint8_t fru_ld[16];
uint8_t fru_text[16];
uint64_t timestamp;
uint8_t data[1]; // error_data_length
} __attribute__((packed));
struct acpi_generic_error_status_block {
// Bit [0] - Uncorrectable Error Valid
// Bit [1] - Correctable Error Valid
// Bit [2] - Multiple Uncorrectable Errors
// Bit [3] - Multiple Correctable Errors
// Bit [13:4] - Error Data Entry Count: Number of Error Data Entries found in the Data section.
// Bit [31:14] - Reserved
uint32_t block_status;
uint32_t raw_data_offset;
// Length in bytes of the generic error data
uint32_t data_length;
uint32_t error_severity;
// The information contained in this field is a collection of zero
// or more Generic Error Data Entrie
struct acpi_generic_error_data_entry data[];
} __attribute__((packed));
static int check_bert_file(const char *filename, char *buff, size_t buff_size) {
int ret = EXIT_FAILURE;
size_t len;
uint32_t block_status;
FILE *fh = fopen(filename, "rb");
if (fh == NULL) {
telem_log(LOG_ERR, "Failed to open: %s\n", filename);
goto done;
}
len = fread(&block_status, 1, sizeof(block_status), fh);
if (ferror(fh) || (len != sizeof(block_status))){
telem_log(LOG_ERR, "Error reading block_status: %s\n", filename);
goto done;
}
/* Check the "Error Data Entry Count", if 0 then nothing
* to report */
if ((block_status & 0x3FFF) != 0) {
rewind(fh);
/* nc_b64enc_file returns 1 in success and 0 in failure */
if (nc_b64enc_file(fh, buff, buff_size) == 0) {
telem_log(LOG_ERR, "Failed to read payload from: %s\n", filename);
goto done;
}
}
ret = EXIT_SUCCESS;
done:
if (fh) {
fclose(fh);
}
return ret;
}
int main(int argc, char **argv)
{
struct telem_ref *tm_handle = NULL;
char *classification = (char *)telem_record_class;
char *payload;
int ret;
// Following vars are for arg parsing.
int c;
int opt_index = 0;
struct option opts[] = {
{ "config_file", 1, NULL, 'f' },
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'V' },
{ NULL, 0, NULL, 0 }
};
while ((c = getopt_long(argc, argv, "f:hV", opts, &opt_index)) != -1) {
switch (c) {
case 'f':
if (tm_set_config_file(optarg) != 0) {
telem_log(LOG_ERR, "Configuration file"
" path not valid\n");
exit(EXIT_FAILURE);
}
break;
case 'h':
print_usage(argv[0]);
exit(EXIT_SUCCESS);
case 'V':
printf(PACKAGE_VERSION "\n");
exit(EXIT_SUCCESS);
case '?':
exit(EXIT_FAILURE);
}
}
payload = calloc(sizeof(char), MAX_PAYLOAD_LENGTH);
if (!payload) {
telem_log(LOG_ERR, "Unable to allocate more memory.\n");
return -ENOMEM;
}
ret = check_bert_file(bert_record_file, payload, MAX_PAYLOAD_LENGTH);
if (ret == EXIT_FAILURE) {
goto done;
} else {
if (payload[0] == 0) {
/* Nothing to report */
goto done;
}
}
/* Valid payload, send the record */
if ((ret = tm_create_record(&tm_handle, severity, classification,
payload_version)) < 0) {
telem_log(LOG_ERR, "Failed to create record: %s\n", strerror(-ret));
goto done;
}
if ((ret = tm_set_payload(tm_handle, payload)) < 0) {
telem_log(LOG_ERR, "Failed to set record payload: %s\n", strerror(-ret));
goto done;
}
if ((ret = tm_send_record(tm_handle)) < 0) {
telem_log(LOG_ERR, "Failed to send record to daemon: %s\n", strerror(-ret));
goto done;
}
ret = EXIT_SUCCESS;
done:
free(payload);
tm_free_record(tm_handle);
tm_handle = NULL;
return ret;
}
/* vi: set ts=8 sw=8 sts=4 et tw=80 cino=(0: */
+1
View File
@@ -396,6 +396,7 @@ static int process_corefile(nc_string **backtrace)
nc_string_free(*backtrace);
}
*backtrace = nc_string_dup("");
frame_counter = 0;
if (dwfl_getthreads(d_core, thread_cb, backtrace) != DWARF_CB_OK) {
/* We aborted unwinding, due to too many frames.
+6
View File
@@ -23,6 +23,7 @@
#include <unistd.h>
#include <sys/stat.h>
#include "common.h"
#include "log.h"
#include "oops_parser.h"
#include "klog_scanner.h"
@@ -44,6 +45,11 @@ static bool send_data(char *backtrace, char *class, uint32_t severity)
return false;
}
/* Truncate payload if necessary, otherwise nothing will be sent */
if (strlen(backtrace) > MAX_PAYLOAD_LENGTH) {
backtrace[MAX_PAYLOAD_LENGTH-1] = 0;
}
if ((ret = tm_set_payload(handle, backtrace)) < 0) {
telem_log(LOG_ERR, "Failed to set payload: %s", strerror(-ret));
tm_free_record(handle);
+1 -17
View File
@@ -4,8 +4,7 @@ bin_PROGRAMS += \
%D%/telem-record-gen \
%D%/klogscanner \
%D%/pstoreprobe \
%D%/pstoreclean \
%D%/bertprobe
%D%/pstoreclean
%C%_hprobe_SOURCES = %D%/hello.c
%C%_hprobe_LDADD = $(top_builddir)/src/libtelemetry.la
@@ -21,21 +20,6 @@ if HAVE_SYSTEMD_JOURNAL
endif
endif
%C%_bertprobe_SOURCES = %D%/bert_probe.c \
src/nica/b64enc.c
%C%_bertprobe_CFLAGS = $(AM_CFLAGS)
%C%_bertprobe_LDADD = $(top_builddir)/src/libtelemetry.la
%C%_bertprobe_LDFLAGS = \
$(AM_LDFLAGS) \
-pie
if LOG_SYSTEMD
if HAVE_SYSTEMD_JOURNAL
%C%_bertprobe_CFLAGS += $(SYSTEMD_JOURNAL_CFLAGS)
%C%_bertprobe_LDADD += $(SYSTEMD_JOURNAL_LIBS)
endif
endif
%C%_telem_record_gen_SOURCES = %D%/telem_record_gen.c
%C%_telem_record_gen_CFLAGS = \
$(AM_CFLAGS)
+64 -12
View File
@@ -162,6 +162,12 @@ struct oops_pattern oops_patterns_arr[] = {
TM_CRITICAL,
false,
},
{
"BERT: Error records from previous boot:",
"org.clearlinux/bert/debug",
TM_MEDIUM,
false,
},
};
static int oops_patterns_cnt = sizeof(oops_patterns_arr) / sizeof(struct oops_pattern);
@@ -334,6 +340,7 @@ void oops_msg_cleanup(struct oops_log_msg *msg)
static struct oops_log_msg oops_msg;
static bool in_stack_dump = false;
static bool in_bert_dump = false;
static oops_handler_t oops_handler;
@@ -357,6 +364,19 @@ void oops_parser_cleanup()
free_pattern_regex();
}
/*
*
[ 1.609112] BERT: Error records from previous boot:
[ 1.609113] [Hardware Error]: event severity: fatal
[ 1.609115] [Hardware Error]: Error 0, type: fatal
[ 1.609116] [Hardware Error]: section type: unknown, 81212a96-09ed-4996-9471-8d729c8e69ed
[ 1.609117] [Hardware Error]: section length: 0xc10
[ 1.609119] [Hardware Error]: 00000000: 00000001 00000000 00000000 01001002 ................
[ 1.609120] [Hardware Error]: 00000010: 01001002 00000001 c71f0d2f 00000003 ......../.......
[ 1.609122] [Hardware Error]: 00000020: 00000001 0000004f 0c070048 800001ff ....O...H.......
[ 1.609123] [Hardware Error]: 00000030: 02002080 7e15fe03 00000001 00000000 . .....~......
...
*/
void parse_single_line(char *line, size_t size)
{
char *start;
@@ -376,28 +396,30 @@ void parse_single_line(char *line, size_t size)
continue;
}
telem_log(LOG_DEBUG, "Oops start has been detected\n");
oops_msg.pattern = pattern;
oops_msg.lines[oops_msg.length] = strndup(start, (size_t)(line_end - start));
if (oops_msg.lines[oops_msg.length] == NULL) {
//telem_perror("Failed to copy string");
exit(EXIT_FAILURE);
return;
} else {
oops_msg.length++;
}
oops_msg.length++;
in_stack_dump = false;
break;
in_bert_dump = false;
if (strstr(oops_msg.pattern->begin_line, "BERT:")) {
in_bert_dump = true;
}
return;
}
} else {
// If in the middle of oops
if (oops_msg.length >= MAX_LINES) {
fprintf(stderr,"*** MAX_LINES!!\n");
end_found = true;
// } else if (oops_msg.end_line && strstr(start, oops_msg.end_line)) {
// end_found = false;
} else if (strstr(start, "[ end trace")) {
end_found = true;
} else if (!in_stack_dump) {
} else if (!in_stack_dump && !in_bert_dump) {
// This line indicates the beginning of a stack trace;
// the next line is most likely the topmost frame.
if (starts_with(start, line_end, "Call Trace:")) {
@@ -414,6 +436,10 @@ void parse_single_line(char *line, size_t size)
in_stack_dump = false;
end_found = true;
}
} else if (in_bert_dump) {
if (!strstr(start, "[Hardware Error]:")) {
end_found = true;
}
}
/* if a new oops starts, this one has ended */
@@ -551,6 +577,10 @@ static void stack_frame_free(struct stack_frame **head)
while (*head != NULL) {
frame = (*head)->next;
// First free memory allocation for function name
if ((*head)->function) {
free((*head)->function);
}
free(*head);
*head = frame;
}
@@ -558,8 +588,8 @@ static void stack_frame_free(struct stack_frame **head)
/*
* Function parses lines of the format :
* CPU: 2 PID: 6429 Comm: insmod Tainted: P OE 3.19.0-18-generic #18-Ubuntu$
* CPU: 2 PID: 0 Comm: swapper/2 Not tainted 3.10.4-100.fc18.x86_64 #1
* CPU: 2 PID: 6429 Comm: insmod Tainted: POE 3.19.0-18-generic #18-Ubuntu$
* CPU: 2 PID: 0 Comm: swapper/2 Not tainted 3.10.4-100.fc18.x86_64 #1
* CPU: 3 PID: 0 Comm: swapper/3 Not tainted 4.0.5-300.fc22.x86_64 #1
*/
static void parse_kernel_cpu_line(char *line, char **kernel_version, char **tainted)
@@ -808,6 +838,15 @@ static nc_string *parse_backtrace(struct oops_log_msg *msg)
if (str_starts_with_casei(line, "CPU: ") ||
str_starts_with_casei(line, "PID: ")) {
/* Can't assume that these variables (tainted,
* an kernel_version) are not already allocated
* otherwise it will leak memory */
if (tainted) {
free(tainted);
}
if (kernel_version) {
free(kernel_version);
}
parse_kernel_cpu_line(line, &kernel_version, &tainted);
continue;
}
@@ -847,15 +886,28 @@ static nc_string *parse_backtrace(struct oops_log_msg *msg)
return backtrace;
}
static void append_payload(nc_string *payload, struct oops_log_msg *msg)
{
for (int i = 1; i < msg->length; i++) {
nc_string_cat(payload,msg->lines[i]);
nc_string_cat(payload,"\n");
}
}
nc_string *parse_payload(struct oops_log_msg *msg)
{
nc_string *payload, *backtrace;
payload = nc_string_dup("Crash Report:\n");
nc_string_append_printf(payload, "Reason: %s\n", msg->lines[0]);
backtrace = parse_backtrace(msg);
nc_string_cat(payload, backtrace->str);
nc_string_free(backtrace);
if (strstr(msg->lines[0], "BERT:")) {
append_payload(payload, msg);
} else {
backtrace = parse_backtrace(msg);
nc_string_cat(payload, backtrace->str);
nc_string_free(backtrace);
}
return payload;
}
+1 -1
View File
@@ -471,7 +471,7 @@ static int journal_cmd(char *cmd)
static char* concatargs(int argc, char** argv)
{
size_t len = strlen("telem_journal") + 1;
size_t len = 1 + strlen("telem_journal ");
for (int i = 2; i < argc; i++) {
len += strlen(argv[i]) + 1;
}
+14 -5
View File
@@ -354,12 +354,21 @@ static void process_record(TelemDaemon *daemon, client *cl)
buf += cfg_info_size;
header_size = *(uint32_t *)buf;
/* Header size can not be bigger than buffer size bail out early */
if ((uint32_t)header_size >= (uint32_t)cl->size) {
return;
}
message_size = cl->size - (cfg_info_size + header_size);
telem_debug("DEBUG: cl->size: %zu\n", cl->size);
telem_debug("DEBUG: header_size: %zu\n", header_size);
telem_debug("DEBUG: message_size: %zu\n", message_size);
telem_debug("DEBUG: cfg_info_size: %zu\n", cfg_info_size);
assert(message_size > 0); //TODO:Check for min and max limits
telem_debug("DEBUG: cl->size: %ld\n", cl->size);
telem_debug("DEBUG: header_size: %ld\n", header_size);
telem_debug("DEBUG: message_size: %ld\n", message_size);
telem_debug("DEBUG: cfg_info_size: %ld\n", cfg_info_size);
telem_debug("Total: %zu\n", header_size + cfg_info_size + message_size);
/* Check message size bounds */
if (message_size <= 0 || message_size > MAX_PAYLOAD_LENGTH) {
telem_log(LOG_INFO, "Record message size out of bounds\n");
return;
}
msg = (char *)buf + sizeof(uint32_t);
/* Copying the headers as strtok modifies the orginal buffer */
+15 -12
View File
@@ -490,7 +490,7 @@ static bool deliver_record(TelemPostDaemon *daemon, char *headers[], char *body,
return ret;
}
bool process_staged_record(char *filename, bool is_retry, TelemPostDaemon *daemon)
bool process_staged_record(char *filename, TelemPostDaemon *daemon)
{
int k;
bool ret = false;
@@ -530,20 +530,12 @@ bool process_staged_record(char *filename, bool is_retry, TelemPostDaemon *daemo
goto end_processing_file;
}
/* Retries should not be recorded */
if (is_retry == false) {
/** Journal entry **/
save_entry_to_journal(daemon, current_time, headers);
/** Record retention **/
apply_retention_policies(daemon, body);
}
/** Record delivery **/
if (!daemon->record_server_delivery_enabled) {
telem_log(LOG_INFO, "record server delivery disabled\n");
// Not an error condition
ret = true;
goto end_processing_file;
goto end_record_delivery;
}
/** Spool policies **/
@@ -571,6 +563,17 @@ bool process_staged_record(char *filename, bool is_retry, TelemPostDaemon *daemo
/** Deliver or spool **/
ret = deliver_record(daemon, headers, body, cfg_file);
end_record_delivery:
/** Save record once it is properly delivered, if record
* is spooled the record is not saved to journal until
* delievered on a re-try **/
if (ret) {
/** Save to journal **/
save_entry_to_journal(daemon, current_time, headers);
/** Record retention **/
apply_retention_policies(daemon, body);
}
end_processing_file:
/** Update spool size if record will be removed **/
if (ret) {
@@ -625,7 +628,7 @@ int staging_records_loop(TelemPostDaemon *daemon)
telem_log(LOG_ERR, "Failed to allocate memory for staging record full path\n");
exit(EXIT_FAILURE);
}
if (process_staged_record(record_path, true, daemon)) {
if (process_staged_record(record_path, daemon)) {
unlink(record_path);
processed++;
}
@@ -721,7 +724,7 @@ void run_daemon(TelemPostDaemon *daemon)
exit(EXIT_FAILURE);
}
/* Process inotify event */
if (process_staged_record(record_name, false, daemon)) {
if (process_staged_record(record_name, daemon)) {
unlink(record_name);
}
free(record_name);
+2 -3
View File
@@ -85,11 +85,9 @@ void close_daemon(TelemPostDaemon *daemon);
* Processed record written on disk
*
* @param filename a pointor to record on disk
* @param is_retry a boolean value that indicates if
* the record has been previously processed.
* @param daemon post to telemetry post daemon
*/
bool process_staged_record(char *filename, bool is_retry, TelemPostDaemon *daemon);
bool process_staged_record(char *filename, TelemPostDaemon *daemon);
/**
* Scans staging directory to process files that were
@@ -107,6 +105,7 @@ int staging_records_loop(TelemPostDaemon *daemon);
* @param body a pointer to the payload
* @param cfg_file a pointer to a non-default configuration
* file to be used.
* @return true if successful, false otherwise
*/
bool post_record_http(char *headers[], char *body, char *cfg_file);
+12 -2
View File
@@ -14,8 +14,10 @@
* details.
*/
#include <stdlib.h>
#include <check.h>
#include "configuration.h"
#include "configuration_check.h"
START_TEST(check_read_config_for_invalid_file)
{
@@ -52,6 +54,7 @@ START_TEST(check_read_valid_config)
"X-Telemetry-TID: 6907c830-eed9-4ce9-81ae-76daf8d88f0f");
ck_assert(config.boolValues[CONF_DAEMON_RECYCLING_ENABLED] == true);
free_config_struct(&config);
}
END_TEST
@@ -80,6 +83,8 @@ START_TEST(check_default_config)
ck_assert(config.boolValues[CONF_DAEMON_RECYCLING_ENABLED] == DEFAULT_DAEMON_RECYCLING_ENABLED);
ck_assert(config.boolValues[CONF_RECORD_RETENTION_ENABLED] == DEFAULT_RECORD_RETENTION_ENABLED);
ck_assert(config.boolValues[CONF_RECORD_SERVER_DELIVERY_ENABLED] == DEFAULT_RECORD_SERVER_DELIVERY_ENABLED);
free_config_struct(&config);
}
END_TEST
@@ -110,6 +115,8 @@ START_TEST(check_layered_config)
ck_assert(config.boolValues[CONF_DAEMON_RECYCLING_ENABLED] == DEFAULT_DAEMON_RECYCLING_ENABLED);
ck_assert(config.boolValues[CONF_RECORD_RETENTION_ENABLED] == DEFAULT_RECORD_RETENTION_ENABLED);
ck_assert(config.boolValues[CONF_RECORD_SERVER_DELIVERY_ENABLED] == DEFAULT_RECORD_SERVER_DELIVERY_ENABLED);
free_config_struct(&config);
}
END_TEST
@@ -123,6 +130,8 @@ START_TEST(check_read_valid_config_record_retention_delivery)
ck_assert(config.boolValues[CONF_RECORD_RETENTION_ENABLED] == true);
ck_assert(config.boolValues[CONF_RECORD_SERVER_DELIVERY_ENABLED] == false);
free_config_struct(&config);
}
END_TEST
@@ -176,6 +185,7 @@ int main(void)
{
Suite *s;
SRunner *sr;
int failed;
s = config_suite();
sr = srunner_create(s);
@@ -186,13 +196,13 @@ int main(void)
srunner_set_tap(sr, "-");
srunner_run_all(sr, CK_SILENT);
// failed = srunner_ntests_failed(sr);
failed = srunner_ntests_failed(sr);
srunner_free(sr);
// if you want the TAP driver to report a hard error based
// on certain conditions (e.g. number of failed tests, etc.),
// return non-zero here instead.
return 0;
return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
/* vi: set ts=8 sw=8 sts=4 et tw=80 cino=(0: */
+4 -2
View File
@@ -17,6 +17,7 @@
#include <check.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
#include "journal/journal.h"
@@ -239,6 +240,7 @@ int main(void)
{
Suite *s;
SRunner *sr;
int failed;
s = config_suite();
sr = srunner_create(s);
@@ -249,13 +251,13 @@ int main(void)
srunner_set_tap(sr, "-");
srunner_run_all(sr, CK_SILENT);
// failed = srunner_ntests_failed(sr);
failed = srunner_ntests_failed(sr);
srunner_free(sr);
// if you want the TAP driver to report a hard error based
// on certain conditions (e.g. number of failed tests, etc.),
// return non-zero here instead.
return 0;
return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
/* vi: set ts=8 sw=8 sts=4 et tw=80 cino=(0: */
+7 -5
View File
@@ -243,9 +243,8 @@ END_TEST
void event_id_teardown(void)
{
if (ref) {
free(ref);
}
// Free record
create_teardown();
free(original_event_id);
}
@@ -292,6 +291,7 @@ int main(void)
{
Suite *s;
SRunner *sr;
int failed;
s = lib_suite();
sr = srunner_create(s);
@@ -299,11 +299,13 @@ int main(void)
srunner_set_log(sr, NULL);
srunner_set_tap(sr, "-");
// set CK_NOFORK to attach gdb
// srunner_set_fork_status(sr, CK_NOFORK);
srunner_run_all(sr, CK_SILENT);
failed = srunner_ntests_failed(sr);
srunner_free(sr);
return 0;
return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
/* vi: set ts=8 sw=8 sts=4 et tw=80 cino=(0: */
-192
View File
@@ -1,192 +0,0 @@
/*
* This program is part of the Clear Linux Project
*
* Copyright 2017 Intel Corporation
*
* This program is free software; you can redistribute it and/or modify it under
* the terms and conditions of the GNU Lesser General Public License, as
* published by the Free Software Foundation; either version 2.1 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
#define OUT_MAX_LEN 100
#include <stdio.h>
#include <check.h>
#include "nica/b64enc.h"
START_TEST(check_nc_b64_no_overflow)
{
size_t n = 2;
char out[OUT_MAX_LEN];
const char *filename = TOPSRCDIR "/tests/nc_b64enc_test_files/foobar";
ck_assert_msg(!nc_b64enc_filename(filename, &out[0], n), "Should quit since buffer smaller than content");
}
END_TEST
START_TEST(check_nc_b64_enc_n_file_empty)
{
size_t n = OUT_MAX_LEN;
char out[OUT_MAX_LEN];
char *result = "\0";
const char *filename = TOPSRCDIR "/tests/nc_b64enc_test_files/empty";
ck_assert_msg(nc_b64enc_filename(filename, &out[0], n), "Error opening file");
ck_assert_str_eq(out, result);
}
END_TEST
START_TEST(check_nc_b64_enc_n_file_fo)
{
size_t n = OUT_MAX_LEN;
char out[OUT_MAX_LEN];
char *result = "Zm8=";
const char *filename = TOPSRCDIR "/tests/nc_b64enc_test_files/fo";
ck_assert_msg(nc_b64enc_filename(filename, &out[0], n), "Error opening file");
ck_assert_str_eq(out, result);
}
END_TEST
START_TEST(check_nc_b64_enc_n_file_foob)
{
size_t n = OUT_MAX_LEN;
char out[OUT_MAX_LEN];
char *result = "Zm9vYg==";
const char *filename = TOPSRCDIR "/tests/nc_b64enc_test_files/foob";
ck_assert_msg(nc_b64enc_filename(filename, &out[0], n), "Error opening file");
ck_assert_str_eq(out, result);
}
END_TEST
START_TEST(check_nc_b64_enc_n_file_foobar)
{
size_t n = OUT_MAX_LEN;
char out[OUT_MAX_LEN];
char *result = "Zm9vYmFyZm9vYmFy";
const char *filename = TOPSRCDIR "/tests/nc_b64enc_test_files/foobar";
ck_assert_msg(nc_b64enc_filename(filename, &out[0], n), "Error opening file");
ck_assert_str_eq(out, result);
}
END_TEST
START_TEST(check_nc_b64_enc_n_file_long_text)
{
size_t out_len = 8000;
char out[out_len];
const char *expected_out = \
"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIG5vbnVtbXkgdml0YWUsIGluIHZpdmFtdXMgc3Vz\n"
"cGVuZGlzc2UgYWMuIFNlbXBlciBzZWQgcGhhcmV0cmEgc2NlbGVyaXNxdWUuIEVnZXQgZWxlaWZl\n"
"bmQgYW1ldCB2ZWwgbnVuYyB2b2x1dHBhdCBjdXJzdXMsIGF1Y3RvciBwbGF0ZWEgcHJldGl1bSwg\n"
"bWF0dGlzIHJpc3VzIGZhY2lsaXNpcyBmYXVjaWJ1cywgc3VzcGVuZGlzc2UgZGlhbSwgbGVjdHVz\n"
"IG1ldHVzIG51bGxhLiBOdW5jIGp1c3RvIGZhY2lsaXNpIG5hbSBmZWxpcyB2ZWwgbGFvcmVldCwg\n"
"bmliaCBsZW8gbWFzc2Egc3VzcGVuZGlzc2UgYWNjdW1zYW4gY29udmFsbGlzLCBzZWQgcXVpcyBw\n"
"ZWxsZW50ZXNxdWUgZWdlc3RhcywgbG9yZW0gYW50ZSBtb3JiaSBtYXR0aXMgdml0YWUuIFByYWVz\n"
"ZW50IGluIHJ1dHJ1bSBlZ2V0IGFjLCB2aXZhbXVzIHBlZGUgc3VzcGVuZGlzc2UgbGVjdHVzIG51\n"
"bGxhbSwgZXQgcGVkZSBldSBvZGlvIHBlZGUsIGV0aWFtIGxlbyBlZ2VzdGFzIGluLCBub251bW15\n"
"IHNlbXBlci4gQSBhY2N1bXNhbiBkdWksIHZlc3RpYnVsdW0gcmlkaWN1bHVzIGV0IGluLCBqdXN0\n"
"byBldCBwbGFjZXJhdCBkdWlzIHV0IHZpdmFtdXMgbGliZXJvLiBWZXN0aWJ1bHVtIGVnZXQgdXQg\n"
"bW9sbGlzLCBudW5jIGEgc29sbGljaXR1ZGluLCBmcmluZ2lsbGEgZXJvcyBwb3N1ZXJlIG1vbGxp\n"
"cyBhYyBuYXRvcXVlIHBlZGUsIHJpc3VzIG51bGxhIHJ1dHJ1bSB0dXJwaXMgYSB2aXRhZSBpZC4g\n"
"SW5jZXB0b3MgdGluY2lkdW50IHF1aWRlbSBhcmN1IHR1cnBpcyBudW5jIHNvbGxpY2l0dWRpbi4g\n"
"UGhhc2VsbHVzIG1ldHVzIGVyYXQgcGxhY2VyYXQsIGluIGVyYXQgbG9yZW0gbWF1cmlzIG51bGxh\n"
"LCBhdCBsaWJlcm8gZXJhdCBzdXNwZW5kaXNzZSBzYXBpZW4gbW9udGVzIHJob25jdXMsIG1hZ25h\n"
"IHF1YW0uIEp1c3RvIHByYWVzZW50IGxhY3VzIG1hc3NhLCByZXByZWhlbmRlcml0IG51bmMsIHJp\n"
"c3VzIGRpZ25pc3NpbSBmZWxpcyBub24sIGRpZ25pc3NpbSBvZGlvIHRlbGx1cyBhbGlxdWFtLCBl\n"
"bmltIHNvZGFsZXMgdGVtcG9yIHF1aXNxdWUgc29kYWxlcyBtYWduaXMgcG9ydHRpdG9yLiBMaWd1\n"
"bGEgc2VkIHJpc3VzLCBldSBlc3QgcXVpc3F1ZSwgY2xhc3Mgbm9uIGF1dGUgZXUsIHBsYXRlYSBz\n"
"Y2VsZXJpc3F1ZSBpZCBpbnRlZ2VyIGRpZ25pc3NpbW9zIGludGVnZXIgc3VzY2lwaXQuClZlaGlj\n"
"dWxhIGVpdXMgbmVjLCBjb252YWxsaXMgbWFlY2VuYXMgbGVjdHVzIHB1cnVzIHF1aXNxdWUgYWxp\n"
"cXVhbSwgZXQgZXQsIGxhY2luaWEgZGlzIGRpZ25pc3NpbSBsb3JlbS4gVm9sdXB0YXRlbSB1dCwg\n"
"dml2ZXJyYSBhZW5lYW4gcGhhc2VsbHVzIGZlbGlzLCBmZXJtZW50dW0gbGlndWxhIGVnZXQgdWxs\n"
"YW1jb3JwZXIgYW1ldCwgbWF1cmlzIGxlbyBsdWN0dXMuIEV0IGV0aWFtIHNlbXBlciBwaGFyZXRy\n"
"YSBuaWJoIG1pIG1hdXJpcy4gSGVuZHJlcml0IHNlZCBhbGlxdWFtLCBlZ2V0IGlkIHRlbGx1cyBt\n"
"YWduYSwgc2VkIGxhb3JlZXQgdWx0cmljZXMgZW5pbSwgbW9sbGlzIHN1c3BlbmRpc3NlIGluLiBF\n"
"dSBudWxsYW0gbG9yZW0gc2l0IGV0aWFtLCBvcmNpIGluIGxpYmVyby4gTnVuYyBpcHN1bSBtYXVy\n"
"aXMgZXQgc2VtIGhhYy4gRGljdHVtIGZhdWNpYnVzIGRpcyB2aXRhZSBpbiB2b2x1dHBhdCBtb3Ji\n"
"aSwgYSBkaWN0dW0sIHF1aXNxdWUgbWF1cmlzLCBhdWN0b3IgbmVjIHZlbCBwZWxsZW50ZXNxdWUg\n"
"dWxsYW1jb3JwZXIgZXRpYW0uIEN1bSBsaWJlcm8gd2lzaSBhY2N1bXNhbiBhbGlxdWFtIGNvbnNl\n"
"Y3RldHVlciB0ZWxsdXMsIHBoYXNlbGx1cyBjdXJhZSwgYXQgaWxsdW0gYW50ZSBwcmV0aXVtIG5p\n"
"YmggbW9yYmkuIFNlZCBibGFuZGl0IHB1bHZpbmFyIHB1bHZpbmFyLiBEaWN0dW0gZXN0IG51bmMg\n"
"ZWxlaWZlbmQsIHZlbGl0IHZlbGl0IHRlbXBvciBhY2N1bXNhbiBsb2JvcnRpcyBsYW9yZWV0IGNv\n"
"bmd1ZS4gU2l0IGFtZXQsIHNlZCBuaWJoIHBvcnJvIG5lcXVlIGF1Y3RvciBoeW1lbmFlb3MgcG9z\n"
"dWVyZSwgb2RpbyBudWxsYSBibGFuZGl0IGNvbmd1ZSBlbGl0LiBJZCBmYXVjaWJ1cyBldCB0ZW1w\n"
"dXMgbWFsZXN1YWRhIHBsYXRlYS4=";
const char *filename = TOPSRCDIR "/tests/nc_b64enc_test_files/long_text";
ck_assert_msg(nc_b64enc_filename(filename, &out[0], out_len), "Error opening file");
ck_assert_str_eq(out, expected_out);
}
END_TEST
START_TEST(check_nc_b64_enc_n_filehandler_foobar)
{
size_t n = OUT_MAX_LEN;
char out[OUT_MAX_LEN];
char *result = "Zm9vYmFyZm9vYmFy";
const char *filename = TOPSRCDIR "/tests/nc_b64enc_test_files/foobar";
FILE *fh = NULL;
fh = fopen(filename, "rb");
if (fh == NULL) {
ck_abort_msg("Unable to open foobar file");
}
ck_assert_msg(nc_b64enc_file(fh, &out[0], n), "Result does not match");
ck_assert_str_eq(out, result);
}
END_TEST
Suite *config_suite(void)
{
// A suite is comprised of test cases, defined below
Suite *s = suite_create("nc_b64enc");
// Individual unit tests are added to "test cases"
TCase *t = tcase_create("nc_b64enc");
tcase_add_test(t, check_nc_b64_no_overflow);
tcase_add_test(t, check_nc_b64_enc_n_file_empty);
tcase_add_test(t, check_nc_b64_enc_n_file_fo);
tcase_add_test(t, check_nc_b64_enc_n_file_foob);
tcase_add_test(t, check_nc_b64_enc_n_file_foobar);
tcase_add_test(t, check_nc_b64_enc_n_file_long_text);
tcase_add_test(t, check_nc_b64_enc_n_filehandler_foobar);
suite_add_tcase(s, t);
return s;
}
int main(void)
{
Suite *s;
SRunner *sr;
s = config_suite();
sr = srunner_create(s);
// Use the TAP driver for now, so that each
// unit test will PASS/FAIL in the log output.
srunner_set_log(sr, NULL);
srunner_set_tap(sr, "-");
srunner_run_all(sr, CK_SILENT);
// failed = srunner_ntests_failed(sr);
srunner_free(sr);
// if you want the TAP driver to report a hard error based
// on certain conditions (e.g. number of failed tests, etc.),
// return non-zero here instead.
return 0;
}
/* vi: set ts=8 sw=8 sts=4 et tw=80 cino=(0: */
+7 -6
View File
@@ -62,7 +62,7 @@ START_TEST(check_handle_client_with_no_data)
bool success;
char *filename = ABSTOPSRCDIR "/tests/telempostd/empty_message";
success = process_staged_record(filename, false, &tdaemon);
success = process_staged_record(filename, &tdaemon);
// Return true to remove corrupted record
ck_assert(success == true);
}
@@ -75,7 +75,7 @@ START_TEST(check_handle_client_with_incorrect_data)
bool success;
char *filename = ABSTOPSRCDIR "/tests/telempostd/incorrect_message";
success = process_staged_record(filename, false, &tdaemon);
success = process_staged_record(filename, &tdaemon);
// Return true to remove corrupted record
ck_assert(success == true);
}
@@ -88,7 +88,7 @@ START_TEST(check_process_record_with_correct_size_and_data)
bool success;
char *filename = ABSTOPSRCDIR "/tests/telempostd/correct_message";
success = process_staged_record(filename, false, &tdaemon);
success = process_staged_record(filename, &tdaemon);
ck_assert(success == true);
}
END_TEST
@@ -100,7 +100,7 @@ START_TEST(check_process_record_with_incorrect_headers)
bool success;
char *filename = ABSTOPSRCDIR "/tests/telempostd/incorrect_headers";
success = process_staged_record(filename, false, &tdaemon);
success = process_staged_record(filename, &tdaemon);
// Return true to remove corrupted record
ck_assert(success == true);
}
@@ -421,6 +421,7 @@ int main(void)
{
Suite *s;
SRunner *sr;
int failed;
s = config_suite();
sr = srunner_create(s);
@@ -431,13 +432,13 @@ int main(void)
srunner_set_tap(sr, "-");
srunner_run_all(sr, CK_SILENT);
// failed = srunner_ntests_failed(sr);
failed = srunner_ntests_failed(sr);
srunner_free(sr);
// if you want the TAP driver to report a hard error based
// on certain conditions (e.g. number of failed tests, etc.),
// return non-zero here instead.
return 0;
return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
/* vi: set ts=8 sw=8 sts=4 et tw=80 cino=(0: */
+30 -5
View File
@@ -22,6 +22,7 @@
#include <unistd.h>
#include "configuration.h"
#include "configuration_check.h"
#include "telemdaemon.h"
#include "common.h"
@@ -61,12 +62,19 @@ void setup(void)
initialize_probe_daemon(&tdaemon);
}
void teardown(void)
{
free_config_file();
}
START_TEST(check_daemon_is_initialized)
{
setup();
ck_assert(tdaemon.nfds == 0);
ck_assert(tdaemon.pollfds == NULL);
teardown();
}
END_TEST
@@ -84,9 +92,9 @@ START_TEST(check_add_del_poll_fd)
int fd = 1;
int short events = 1;
add_pollfd(&tdaemon, fd, events);
add_pollfd(&tdaemon, ++fd, events);
add_pollfd(&tdaemon, ++fd, events);
add_pollfd(&tdaemon, 1, events);
add_pollfd(&tdaemon, 2, events);
add_pollfd(&tdaemon, 3, events);
ck_assert_msg(tdaemon.nfds == 3, "Failed to add pollfd");
fd = get_poll_fd(&tdaemon, 0);
@@ -110,6 +118,10 @@ START_TEST(check_add_del_poll_fd)
ck_assert_msg(tdaemon.nfds == 0, "Failed to delete pollfd");
fd = get_poll_fd(&tdaemon, 0);
ck_assert(fd == -1);
/* Cleaning alloctions */
free(tdaemon.pollfds);
teardown();
}
END_TEST
@@ -133,6 +145,8 @@ START_TEST(check_add_remove_client)
remove_client(&(tdaemon.client_head), cl3);
//ck_assert(tdaemon.client_head.lh_first == NULL);
ck_assert_msg(is_client_list_empty(&(tdaemon.client_head)), "Failed to remove clients\n");
teardown();
}
END_TEST
@@ -171,6 +185,8 @@ START_TEST(check_handle_client_with_no_data)
ck_assert_msg(is_client_list_empty(&(tdaemon.client_head)), "Failed to remove client with no data\n");
ck_assert_msg(tdaemon.nfds == 0, "Failed to remove poll fd for client with n data\n");
close(server_fd);
teardown();
}
END_TEST
@@ -197,6 +213,8 @@ START_TEST(check_handle_client_with_incorrect_data)
ck_assert_msg(is_client_list_empty(&(tdaemon.client_head)), "Failed to remove client with no data\n");
ck_assert_msg(tdaemon.nfds == 0, "Failed to remove poll fd for client with n data\n");
close(server_fd);
teardown();
}
END_TEST
@@ -228,6 +246,8 @@ START_TEST(check_handle_client_with_incorrect_size)
ck_assert_msg(is_client_list_empty(&(tdaemon.client_head)), "Failed to remove client with no data\n");
ck_assert_msg(tdaemon.nfds == 0, "Failed to remove poll fd for client with n data\n");
close(server_fd);
teardown();
}
END_TEST
@@ -332,6 +352,8 @@ START_TEST(check_process_record_with_incorrect_headers)
ck_assert_msg(tdaemon.nfds == 0, "Failed to remove poll fd for client with incorrect headers\n");
close(server_fd);
free(record);
teardown();
}
END_TEST
@@ -361,6 +383,7 @@ int main(void)
{
Suite *s;
SRunner *sr;
int failed;
s = config_suite();
sr = srunner_create(s);
@@ -370,14 +393,16 @@ int main(void)
srunner_set_log(sr, NULL);
srunner_set_tap(sr, "-");
// set CK_NOFORK to attach gdb
// srunner_set_fork_status(sr, CK_NOFORK);
srunner_run_all(sr, CK_SILENT);
// failed = srunner_ntests_failed(sr);
failed = srunner_ntests_failed(sr);
srunner_free(sr);
// if you want the TAP driver to report a hard error based
// on certain conditions (e.g. number of failed tests, etc.),
// return non-zero here instead.
return 0;
return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
/* vi: set ts=8 sw=8 sts=4 et tw=80 cino=(0: */
+11 -23
View File
@@ -57,6 +57,10 @@ void setup_payload(char *oopsfile)
oops_parser_init(callback_func);
split_buf_by_line(buf, buflen);
}
if (buf) {
free(buf);
}
}
// Tests for checking backtrace
@@ -249,6 +253,8 @@ START_TEST(sysctl1_payload)
ck_assert(strstr(pl->str, "#24 sys_ioctl"));
ck_assert(strstr(pl->str, "#25 sysenter_past_esp"));
ck_assert(strstr(pl->str, "#26 quirk_ali7101_acpi"));
nc_string_free(pl);
}
END_TEST
@@ -679,27 +685,6 @@ Suite *config_suite(void)
tcase_add_test(t, bug_kernel_handle_payload);
tcase_add_test(t, bug_kernel_handle_payload_new_format);
//TODO fix
//tcase_add_test(t, badness_payload);
/*
tcase_add_test(t, watchdog_oops);
tcase_add_test(t, warning_oops);
tcase_add_test(t, warn_on_oops);
tcase_add_test(t, two_warnings_oops);
tcase_add_test(t, sysctl1_oops);
tcase_add_test(t, sysctl2_oops);
tcase_add_test(t, softlockup_oops);
tcase_add_test(t, rtnl_oops);
tcase_add_test(t, kernel_null_pointer_oops);
tcase_add_test(t, kernel_bug_oops);
tcase_add_test(t, irq_oops);
tcase_add_test(t, general_protection_fault_oops);
tcase_add_test(t, double_fault_oops);
tcase_add_test(t, bad_page_map_oops);
tcase_add_test(t, bug_kernel_handle_oops);
tcase_add_test(t, badness_oops);
*/
suite_add_tcase(s, t);
return s;
@@ -709,6 +694,7 @@ int main(void)
{
Suite *s;
SRunner *sr;
int failed;
s = config_suite();
sr = srunner_create(s);
@@ -720,14 +706,16 @@ int main(void)
srunner_set_log(sr, NULL);
srunner_set_tap(sr, "-");
// set CK_NOFORK to attach gdb
// srunner_set_fork_status(sr, CK_NOFORK);
srunner_run_all(sr, CK_SILENT);
// failed = srunner_ntests_failed(sr);
failed = srunner_ntests_failed(sr);
srunner_free(sr);
// if you want the TAP driver to report a hard error based
// on certain conditions (e.g. number of failed tests, etc.),
// return non-zero here instead.
return 0;
return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
/* vi: set ts=8 sw=8 sts=4 et tw=80 cino=(0: */
+24
View File
@@ -0,0 +1,24 @@
/*
* This program is part of the Clear Linux Project
*
* Copyright 2020 Intel Corporation
*
* This program is free software; you can redistribute it and/or modify it under
* the terms and conditions of the GNU Lesser General Public License, as
* published by the Free Software Foundation; either version 2.1 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
#pragma once
/* Function used only for unit testing */
/* Frees configuration structure */
void free_config_struct(struct configuration *config);
/* Frees configuration file name string */
void free_config_file(void);
+15 -21
View File
@@ -1,4 +1,6 @@
EXTRA_DIST += %D%/taplib.sh
EXTRA_DIST += \
%D%/taplib.sh \
%D%/telemetrics-client.supp
TEST_EXTENSIONS = .sh
@@ -15,7 +17,6 @@ check_PROGRAMS = \
%D%/check_probd \
%D%/check_postd \
%D%/check_probes \
%D%/check_ncb64 \
%D%/check_journal \
%D%/check_libtelemetry
@@ -23,6 +24,7 @@ dist_check_SCRIPTS = \
%D%/create-core.sh
%C%_check_config_SOURCES = \
%D%/configuration_check.h \
%D%/check_config.c
%C%_check_config_CFLAGS = \
@@ -41,6 +43,7 @@ endif
endif
%C%_check_probd_SOURCES = \
%D%/configuration_check.h \
%D%/check_probd.c \
src/telemdaemon.c \
src/telemdaemon.h \
@@ -155,25 +158,6 @@ if HAVE_SYSTEMD_JOURNAL
endif
endif
%C%_check_ncb64_SOURCES = \
%D%/check_ncb64.c \
src/nica/b64enc.h \
src/nica/b64enc.c
%C%_check_ncb64_CFLAGS = \
$(AM_CFLAGS) \
@CHECK_CFLAGS@
%C%_check_ncb64_LDADD = \
@CHECK_LIBS@
EXTRA_DIST += \
%D%/nc_b64enc_test_files/empty \
%D%/nc_b64enc_test_files/fo \
%D%/nc_b64enc_test_files/foob \
%D%/nc_b64enc_test_files/foobar \
%D%/nc_b64enc_test_files/long_text
%C%_check_journal_SOURCES = \
%D%/check_journal.c \
src/journal/journal.c \
@@ -216,4 +200,14 @@ if LOG_SYSTEMD
endif
endif
@VALGRIND_CHECK_RULES@
VALGRIND_SUPPRESSIONS_FILES = %D%/telemetrics-client.supp
VALGRIND_FLAGS = \
--error-exitcode=1 \
--track-origins=yes \
--leak-resolution=low \
--verbose \
--leak-check=full \
--show-possibly-lost=no
# vim: filetype=automake tabstop=8 shiftwidth=8 noexpandtab
+17 -9
View File
@@ -1,3 +1,19 @@
/*
* This program is part of the Clear Linux Project
*
* Copyright 2015 Intel Corporation
*
* This program is free software; you can redistribute it and/or modify it under
* the terms and conditions of the GNU Lesser General Public License, as
* published by the Free Software Foundation; either version 2.1 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
@@ -36,26 +52,18 @@ char *readfile(char *filepath)
if (fread(bufp, sizeof(char), buflen, fp) != buflen) {
telem_log(LOG_ERR, "Error reading file\n");
} else {
bufp[++buflen] = '\0';
bufp[buflen] = '\0';
}
}
if (fclose(fp) != 0) {
printf("Error closing file: %s\n", strerror(errno));
}
//free(bufp);
} else {
telem_log(LOG_ERR, "Wrong file pathname: %s", filepath);
}
return bufp;
}
/*
char *getbuf()
{
return bufp;
}
*/
unsigned long getbuflen()
{
+38
View File
@@ -0,0 +1,38 @@
# This program is part of the Clear Linux Project
#
# Copyright 2020 Intel Corporation
#
# This program is free software; you can redistribute it and/or modify it under
# the terms and conditions of the GNU Lesser General Public License, as
# published by the Free Software Foundation; either version 2.1 of the License,
# or (at your option) any later version.
#
# This program is distributed in the hope it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
# False positive when check is run with CK_FORK=yes
{
ck_fork_yes_false_positive
Memcheck:Leak
fun:malloc
fun:UnknownInlinedFun
fun:UnknownInlinedFun
fun:tag_string_to_list
fun:UnknownInlinedFun
fun:srunner_run_tagged
fun:main
}
# False positive returned by call to shell script from
# with in test.
{
ck_shell_call
Memcheck:Leak
fun:malloc
fun:xmalloc
fun:set_default_locale
fun:main
}