Skip to content
Permalink
Browse files

Merge pull request #31 from AVSystem/staging

Anjay 1.16
  • Loading branch information...
dextero committed Sep 13, 2019
2 parents 0e19944 + c4fda35 commit ffba5f166c6c40e3c6144dd96fe0e2c4233c8277
@@ -39,66 +39,66 @@ matrix:
env: ANJAY_CC=gcc-4.7
ANJAY_CXX=g++
PYMBEDTLS_CC=gcc
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_URL_CHECK=OFF -DNPROC=1"
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_VALGRIND_TRACK_ORIGINS=OFF -DWITH_URL_CHECK=OFF -DNPROC=1"
DOCKER_IMAGE=ubuntu-16.04

- stage: test
os: linux
env: ANJAY_CC=gcc-4.8
ANJAY_CXX=g++
PYMBEDTLS_CC=gcc
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_URL_CHECK=OFF -DNPROC=1"
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_VALGRIND_TRACK_ORIGINS=OFF -DWITH_URL_CHECK=OFF -DNPROC=1"
DOCKER_IMAGE=ubuntu-16.04

- stage: test
os: linux
env: ANJAY_CC=gcc-4.9
ANJAY_CXX=g++
PYMBEDTLS_CC=gcc
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_URL_CHECK=OFF -DNPROC=1"
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_VALGRIND_TRACK_ORIGINS=OFF -DWITH_URL_CHECK=OFF -DNPROC=1"
DOCKER_IMAGE=ubuntu-16.04

- stage: test
os: linux
env: ANJAY_CC=gcc-5
ANJAY_CXX=g++-5
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_URL_CHECK=OFF -DNPROC=1"
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_VALGRIND_TRACK_ORIGINS=OFF -DWITH_URL_CHECK=OFF -DNPROC=1"
DOCKER_IMAGE=ubuntu-16.04

- stage: test
os: linux
env: ANJAY_CC=clang-3.5
ANJAY_CXX=clang++-3.5
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_URL_CHECK=OFF -DNPROC=1"
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_VALGRIND_TRACK_ORIGINS=OFF -DWITH_URL_CHECK=OFF -DNPROC=1"
DOCKER_IMAGE=ubuntu-16.04

- stage: test
os: linux
env: ANJAY_CC=clang-3.6
ANJAY_CXX=clang++-3.6
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_URL_CHECK=OFF -DNPROC=1"
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_VALGRIND_TRACK_ORIGINS=OFF -DWITH_URL_CHECK=OFF -DNPROC=1"
DOCKER_IMAGE=ubuntu-16.04

- stage: test
os: linux
env: ANJAY_CC=clang-3.7
ANJAY_CXX=clang++-3.7
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_URL_CHECK=OFF -DNPROC=1"
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_VALGRIND_TRACK_ORIGINS=OFF -DWITH_URL_CHECK=OFF -DNPROC=1"
DOCKER_IMAGE=ubuntu-16.04

- stage: test
os: linux
env: ANJAY_CC=clang-3.8
ANJAY_CXX=clang++-3.8
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_URL_CHECK=OFF -DNPROC=1"
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_VALGRIND_TRACK_ORIGINS=OFF -DWITH_URL_CHECK=OFF -DNPROC=1"
DOCKER_IMAGE=ubuntu-16.04

- stage: test
os: linux
env: ANJAY_CC=gcc
ANJAY_CXX=g++
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_URL_CHECK=OFF -DNPROC=1"
DOCKER_IMAGE=centos7
DEVCONFIG_FLAGS="--with-valgrind --without-analysis -DWITH_VALGRIND_TRACK_ORIGINS=OFF -DWITH_URL_CHECK=OFF -DNPROC=1"
DOCKER_IMAGE=centos-7

- stage: coverity
os: linux
@@ -15,7 +15,7 @@
cmake_minimum_required(VERSION 2.8.12)

project(anjay C)
set(ANJAY_VERSION "1.15.5" CACHE STRING "Anjay library version")
set(ANJAY_VERSION "1.16" CACHE STRING "Anjay library version")
set(ANJAY_BINARY_VERSION 1.0.0)

set(ANJAY_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
@@ -410,6 +410,7 @@ if(WITH_LOCAL_AVS_COMMONS)

find_program(VALGRIND_EXECUTABLE valgrind)
cmake_dependent_option(WITH_VALGRIND "Enable usage of valgrind during unit tests" OFF "VALGRIND_EXECUTABLE" OFF)
cmake_dependent_option(WITH_VALGRIND_TRACK_ORIGINS "Add --track-origins to valgrind command line during unit tests" ON "WITH_VALGRIND" OFF)
endif()
find_package(avs_commons COMPONENTS ${AVS_COMMONS_COMPONENTS} REQUIRED)
else()
@@ -672,7 +673,10 @@ if(WITH_TEST)
set(NPROC "${ANJAY_DEFAULT_NPROC}" CACHE STRING "Number of threads for multi-threaded build/test operations")

if(WITH_VALGRIND)
set(VALGRIND ${VALGRIND_EXECUTABLE} --leak-check=full --track-origins=yes -q --error-exitcode=63 --suppressions=${CMAKE_CURRENT_SOURCE_DIR}/valgrind_test.supp)
set(VALGRIND ${VALGRIND_EXECUTABLE} --leak-check=full -q --error-exitcode=63 --suppressions=${CMAKE_CURRENT_SOURCE_DIR}/valgrind_test.supp)
if(WITH_VALGRIND_TRACK_ORIGINS)
list(APPEND VALGRIND --track-origins=yes)
endif()
endif()

include_directories(test/include)
@@ -39,8 +39,6 @@
#include <anjay/security.h>
#include <anjay/server.h>

char **saved_argv;

static int security_object_reload(anjay_demo_t *demo) {
anjay_security_object_purge(demo->anjay);
const server_connection_args_t *args = demo->connection_args;
@@ -308,12 +306,14 @@ static int demo_init(anjay_demo_t *demo, cmdline_args_t *cmdline_args) {
if (!demo->anjay || !demo->iosched
|| anjay_attr_storage_install(demo->anjay)
|| anjay_access_control_install(demo->anjay)
|| firmware_update_install(demo->anjay, &demo->fw_update,
cmdline_args->fw_updated_marker_path,
fw_security_info_ptr,
cmdline_args->fwu_tx_params_modified
? &cmdline_args->fwu_tx_params
: NULL)) {
|| firmware_update_install(
demo->anjay, demo->iosched, &demo->fw_update,
cmdline_args->fw_updated_marker_path,
fw_security_info_ptr,
cmdline_args->fwu_tx_params_modified
? &cmdline_args->fwu_tx_params
: NULL,
cmdline_args->fw_update_delayed_result)) {
return -1;
}

@@ -390,6 +390,7 @@ static int demo_init(anjay_demo_t *demo, cmdline_args_t *cmdline_args) {
// no success log there, as Attribute Storage module logs it by itself
avs_stream_cleanup(&data);
}

return 0;
}

@@ -566,6 +567,22 @@ int main(int argc, char *argv[]) {
}
#endif // WIN32

/*
* If, as a result of a single poll() more than a single line is read into
* stdin buffer, we will end up handling just a single command and then
* wait for another poll() trigger which may never happen - because all the
* data from fd 0 was already read, and it's just waiting to be read from
* the buffer.
*
* This problematic behavior can be reproduced by sending a "\ncommand\n"
* string to the demo application with a single write() syscall.
*
* Disabling stdin buffering prevents Python tests from hanging randomly.
* While generally that is not a good idea performance-wise, demo commands
* do not require passing large amounts of data, so it is fine in our use
* case.
*/
setbuf(stdin, NULL);
setbuf(stdout, NULL);
setbuf(stderr, NULL);

@@ -574,7 +591,9 @@ int main(int argc, char *argv[]) {
avs_log_set_level(demo, AVS_LOG_DEBUG);
avs_log_set_level(anjay_sched, AVS_LOG_DEBUG);

saved_argv = argv;
if (argv_store(argc, argv)) {
return -1;
}

cmdline_args_t cmdline_args;
if (demo_parse_argv(&cmdline_args, argc, argv)) {
@@ -188,6 +188,10 @@ static void print_option_help(const struct option *opt) {
"it to 0 disables caching mechanism." },
{ 'N', NULL, NULL,
"Send notifications as Confirmable messages by default" },
{ 'r', "RESULT", NULL, "If specified and nonzero, initializes the "
"Firmware Update object in UPDATING state, and "
"sets the result to given value after a short "
"while" },
{ 1, "PATH", DEFAULT_CMDLINE_ARGS.fw_updated_marker_path,
"File path to use as a marker for persisting firmware update state" },
{ 2, "CERT_FILE", NULL, "Require certificate validation against "
@@ -452,6 +456,7 @@ int demo_parse_argv(cmdline_args_t *parsed_args, int argc, char *argv[]) {
{ "outbuf-size", required_argument, 0, 'O' },
{ "cache-size", required_argument, 0, '$' },
{ "confirmable-notifications", no_argument, 0, 'N' },
{ "delayed-upgrade-result", required_argument, 0, 'r' },
{ "fw-updated-marker-path", required_argument, 0, 1 },
{ "fw-cert-file", required_argument, 0, 2 },
{ "fw-cert-path", required_argument, 0, 3 },
@@ -696,6 +701,18 @@ int demo_parse_argv(cmdline_args_t *parsed_args, int argc, char *argv[]) {
case 'N':
parsed_args->confirmable_notifications = true;
break;
case 'r': {
int result;
if (parse_i32(optarg, &result)
|| result < (int) ANJAY_FW_UPDATE_RESULT_INITIAL
|| result > (int) ANJAY_FW_UPDATE_RESULT_UNSUPPORTED_PROTOCOL) {
demo_log(ERROR, "invalid update result value: %s", optarg);
goto finish;
}
parsed_args->fw_update_delayed_result =
(anjay_fw_update_result_t) result;
break;
}
case 1:
parsed_args->fw_updated_marker_path = optarg;
break;
@@ -22,6 +22,7 @@

#include <anjay/access_control.h>
#include <anjay/anjay.h>
#include <anjay/fw_update.h>

typedef struct access_entry {
anjay_ssid_t ssid;
@@ -44,6 +45,14 @@ typedef struct cmdline_args {
#endif // _WIN32
const char *fw_updated_marker_path;
avs_net_security_info_t fw_security_info;
/**
* If nonzero (not @ref ANJAY_FW_UPDATE_RESULT_INITIAL), Firmware Update
* object will be initialized in UPDATING state. In that case,
* @ref anjay_fw_update_set_result will be used after a while to trigger a
* transition to this update result. This simulates a FOTA procedure during
* which the client is restarted while upgrade is still in progress.
*/
anjay_fw_update_result_t fw_update_delayed_result;
const char *attr_storage_file;
bool disable_server_initiated_bootstrap;
avs_coap_tx_params_t tx_params;
@@ -30,6 +30,52 @@

#include "demo_utils.h"

static struct {
size_t argc;
char **argv;
} g_saved_args;

char **argv_get(void) {
AVS_ASSERT(g_saved_args.argv, "argv_store not called before argv_get");
return g_saved_args.argv;
}

int argv_store(int argc, char **argv) {
AVS_ASSERT(argc >= 0, "unexpected negative value of argc");

char **argv_copy = (char **) avs_calloc((size_t) argc + 1, sizeof(char *));
if (!argv_copy) {
return -1;
}

for (size_t i = 0; i < (size_t) argc; ++i) {
argv_copy[i] = argv[i];
}

avs_free(g_saved_args.argv);
g_saved_args.argv = argv_copy;
g_saved_args.argc = (size_t) argc;
return 0;
}

int argv_append(const char *arg) {
assert(arg);

size_t new_argc = g_saved_args.argc + 1;

char **new_argv = (char **) avs_realloc(g_saved_args.argv,
(new_argc + 1) * sizeof(char *));
if (new_argv == NULL) {
return -1;
}

new_argv[new_argc - 1] = (char *) (intptr_t) arg;
new_argv[new_argc] = NULL;
g_saved_args.argv = new_argv;
g_saved_args.argc = new_argc;
return 0;
}

static double geo_distance_m_with_radians(double lat1,
double lon1,
double lat2,
@@ -38,7 +38,9 @@
#define container_of(Ptr, Type, Member) \
((Type *) (intptr_t) ((const char *) (Ptr) -offsetof(Type, Member)))

extern char **saved_argv;
char **argv_get(void);
int argv_store(int argc, char **argv);
int argv_append(const char *arg);

static inline unsigned time_to_rand(void) {
return 1103515245u * (unsigned) avs_time_real_now().since_real_epoch.seconds

0 comments on commit ffba5f1

Please sign in to comment.
You can’t perform that action at this time.