[PATCH] osmo-trx[master]: ssedetect: call __builtin_cpu_supports() only if supported

2017-05-19 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/2690

ssedetect: call __builtin_cpu_supports() only if supported

Some compilers don't support the __builtin_cpu_supports built-in,
so let's make them able to compile the project anyway.

Change-Id: I0c90402d8e4c9f196c54b066ff30891c8de3ad2b
---
M Transceiver52M/osmo-trx.cpp
M Transceiver52M/x86/convert.c
M Transceiver52M/x86/convolve.c
3 files changed, 11 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/90/2690/1

diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp
index 1c0ceb1..31a99cf 100644
--- a/Transceiver52M/osmo-trx.cpp
+++ b/Transceiver52M/osmo-trx.cpp
@@ -397,18 +397,26 @@
 
 #ifdef HAVE_SSE3
printf("Info: SSE3 support compiled in");
+#ifdef HAVE___BUILTIN_CPU_SUPPORTS
if (__builtin_cpu_supports("sse3"))
printf(" and supported by CPU\n");
else
printf(", but not supported by CPU\n");
+#else
+   printf(", but runtime SIMD detection disabled\n");
+#endif
 #endif
 
 #ifdef HAVE_SSE4_1
printf("Info: SSE4.1 support compiled in");
+#ifdef HAVE___BUILTIN_CPU_SUPPORTS
if (__builtin_cpu_supports("sse4.1"))
printf(" and supported by CPU\n");
else
printf(", but not supported by CPU\n");
+#else
+   printf(", but runtime SIMD detection disabled\n");
+#endif
 #endif
 
convolve_init();
diff --git a/Transceiver52M/x86/convert.c b/Transceiver52M/x86/convert.c
index db98050..07cdf59 100644
--- a/Transceiver52M/x86/convert.c
+++ b/Transceiver52M/x86/convert.c
@@ -46,6 +46,7 @@
c.convert_si16_ps_16n = base_convert_short_float;
c.convert_si16_ps = base_convert_short_float;
 
+#ifdef HAVE___BUILTIN_CPU_SUPPORTS
 #ifdef HAVE_SSE4_1
if (__builtin_cpu_supports("sse4.1")) {
c.convert_si16_ps_16n = &_sse_convert_si16_ps_16n;
@@ -60,6 +61,7 @@
c.convert_scale_ps_si16 = _sse_convert_scale_ps_si16;
}
 #endif
+#endif
 }
 
 void convert_float_short(short *out, const float *in, float scale, int len)
diff --git a/Transceiver52M/x86/convolve.c b/Transceiver52M/x86/convolve.c
index 35cba29..eb38f64 100644
--- a/Transceiver52M/x86/convolve.c
+++ b/Transceiver52M/x86/convolve.c
@@ -82,7 +82,7 @@
c.conv_real4n = (void *)_base_convolve_real;
c.conv_real = (void *)_base_convolve_real;
 
-#ifdef HAVE_SSE3
+#if defined(HAVE_SSE3) && defined(HAVE___BUILTIN_CPU_SUPPORTS)
if (__builtin_cpu_supports("sse3")) {
c.conv_cmplx_4n = sse_conv_cmplx_4n;
c.conv_cmplx_8n = sse_conv_cmplx_8n;

-- 
To view, visit https://gerrit.osmocom.org/2690
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0c90402d8e4c9f196c54b066ff30891c8de3ad2b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] osmo-trx[master]: buildenv: actually strip unused cpuid functionality

2017-05-19 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/2686

buildenv: actually strip unused cpuid functionality

Despite the macro message says, that cpuid functionality was stripped
it was still partially preset and wasn't used anyhow.

Change-Id: I380bc9c13d29319685781ef27973afe6744fcf3d
---
D config/ax_gcc_x86_avx_xgetbv.m4
D config/ax_gcc_x86_cpuid.m4
M config/ax_sse.m4
3 files changed, 0 insertions(+), 164 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/86/2686/1

diff --git a/config/ax_gcc_x86_avx_xgetbv.m4 b/config/ax_gcc_x86_avx_xgetbv.m4
deleted file mode 100644
index 0624eeb..000
--- a/config/ax_gcc_x86_avx_xgetbv.m4
+++ /dev/null
@@ -1,79 +0,0 @@
-# ===
-#   http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_avx_xgetbv.html
-# ===
-#
-# SYNOPSIS
-#
-#   AX_GCC_X86_AVX_XGETBV
-#
-# DESCRIPTION
-#
-#   On later x86 processors with AVX SIMD support, with gcc or a compiler
-#   that has a compatible syntax for inline assembly instructions, run a
-#   small program that executes the xgetbv instruction with input OP. This
-#   can be used to detect if the OS supports AVX instruction usage.
-#
-#   On output, the values of the eax and edx registers are stored as
-#   hexadecimal strings as "eax:edx" in the cache variable
-#   ax_cv_gcc_x86_avx_xgetbv.
-#
-#   If the xgetbv instruction fails (because you are running a
-#   cross-compiler, or because you are not using gcc, or because you are on
-#   a processor that doesn't have this instruction),
-#   ax_cv_gcc_x86_avx_xgetbv_OP is set to the string "unknown".
-#
-#   This macro mainly exists to be used in AX_EXT.
-#
-# LICENSE
-#
-#   Copyright (c) 2013 Michael Petch 
-#
-#   This program is free software: you can redistribute it and/or modify it
-#   under the terms of the GNU General Public License as published by the
-#   Free Software Foundation, either version 3 of the License, or (at your
-#   option) any later version.
-#
-#   This program is distributed in the hope that it will be useful, but
-#   WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-#   Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License along
-#   with this program. If not, see .
-#
-#   As a special exception, the respective Autoconf Macro's copyright owner
-#   gives unlimited permission to copy, distribute and modify the configure
-#   scripts that are the output of Autoconf when processing the Macro. You
-#   need not follow the terms of the GNU General Public License when using
-#   or distributing such scripts, even though portions of the text of the
-#   Macro appear in them. The GNU General Public License (GPL) does govern
-#   all other use of the material that constitutes the Autoconf Macro.
-#
-#   This special exception to the GPL applies to versions of the Autoconf
-#   Macro released by the Autoconf Archive. When you make and distribute a
-#   modified version of the Autoconf Macro, you may extend this special
-#   exception to the GPL to apply to your modified version as well.
-
-#serial 1
-
-AC_DEFUN([AX_GCC_X86_AVX_XGETBV],
-[AC_REQUIRE([AC_PROG_CC])
-AC_LANG_PUSH([C])
-AC_CACHE_CHECK(for x86-AVX xgetbv $1 output, ax_cv_gcc_x86_avx_xgetbv_$1,
- [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include ], [
- int op = $1, eax, edx;
- FILE *f;
-  /* Opcodes for xgetbv */
-  __asm__(".byte 0x0f, 0x01, 0xd0"
-: "=a" (eax), "=d" (edx)
-: "c" (op));
- f = fopen("conftest_xgetbv", "w"); if (!f) return 1;
- fprintf(f, "%x:%x\n", eax, edx);
- fclose(f);
- return 0;
-])],
- [ax_cv_gcc_x86_avx_xgetbv_$1=`cat conftest_xgetbv`; rm -f 
conftest_xgetbv],
- [ax_cv_gcc_x86_avx_xgetbv_$1=unknown; rm -f conftest_xgetbv],
- [ax_cv_gcc_x86_avx_xgetbv_$1=unknown])])
-AC_LANG_POP([C])
-])
diff --git a/config/ax_gcc_x86_cpuid.m4 b/config/ax_gcc_x86_cpuid.m4
deleted file mode 100644
index 7d46fee..000
--- a/config/ax_gcc_x86_cpuid.m4
+++ /dev/null
@@ -1,79 +0,0 @@
-# ===
-# http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpuid.html
-# ===
-#
-# SYNOPSIS
-#
-#   AX_GCC_X86_CPUID(OP)
-#
-# DESCRIPTION
-#
-#   On Pentium and later x86 processors, with gcc or a compiler that has a
-#   compatible syntax for inline assembly instructions, run a small program
-#   that executes the cpuid instruction with input OP. This can be used to
-#   detect the CPU type.
-#
-#   On output, the values of the eax, ebx, ecx, and edx registers are stored
-#   as hexadecimal strings as "eax:ebx:ecx:edx" in the cache variable
-#   

[PATCH] osmo-trx[master]: buildenv: cosmetic changes

2017-05-19 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/2688

buildenv: cosmetic changes

Change-Id: I9c52f2981513fa6322bdf992215e3e099ac3ddee
---
M config/ax_sse.m4
1 file changed, 8 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/88/2688/1

diff --git a/config/ax_sse.m4 b/config/ax_sse.m4
index 7d9d7fb..de97124 100644
--- a/config/ax_sse.m4
+++ b/config/ax_sse.m4
@@ -48,19 +48,21 @@
   AX_CHECK_COMPILE_FLAG(-msse3, ax_cv_support_sse3_ext=yes, [])
   if test x"$ax_cv_support_sse3_ext" = x"yes"; then
 SIMD_FLAGS="$SIMD_FLAGS -msse3"
-AC_DEFINE(HAVE_SSE3,,[Support SSE3 (Streaming SIMD Extensions 3) 
instructions])
-   AM_CONDITIONAL(HAVE_SSE3, true)
+AC_DEFINE(HAVE_SSE3,,
+  [Support SSE3 (Streaming SIMD Extensions 3) instructions])
+AM_CONDITIONAL(HAVE_SSE3, true)
   else
-AC_MSG_WARN([Your compiler does not support sse3 instructions, can you 
try another compiler?])
+AC_MSG_WARN([Your compiler does not support SSE3 instructions])
   fi
 
   AX_CHECK_COMPILE_FLAG(-msse4.1, ax_cv_support_sse41_ext=yes, [])
   if test x"$ax_cv_support_sse41_ext" = x"yes"; then
 SIMD_FLAGS="$SIMD_FLAGS -msse4.1"
-AC_DEFINE(HAVE_SSE4_1,,[Support SSE4.1 (Streaming SIMD Extensions 4.1) 
instructions])
-   AM_CONDITIONAL(HAVE_SSE4_1, true)
+AC_DEFINE(HAVE_SSE4_1,,
+  [Support SSE4.1 (Streaming SIMD Extensions 4.1) instructions])
+AM_CONDITIONAL(HAVE_SSE4_1, true)
   else
-AC_MSG_WARN([Your compiler does not support sse4.1 instructions, can 
you try another compiler?])
+AC_MSG_WARN([Your compiler does not support SSE4.1])
   fi
   ;;
   esac

-- 
To view, visit https://gerrit.osmocom.org/2688
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9c52f2981513fa6322bdf992215e3e099ac3ddee
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] osmo-trx[master]: buildenv: correct the ax_sse macro description

2017-05-19 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/2685

buildenv: correct the ax_sse macro description

Change-Id: I4ce65443c8a33ae9add8f6da9d911c3178472ab2
---
M config/ax_sse.m4
1 file changed, 5 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/85/2685/1

diff --git a/config/ax_sse.m4 b/config/ax_sse.m4
index ed4d223..cf363a4 100644
--- a/config/ax_sse.m4
+++ b/config/ax_sse.m4
@@ -4,14 +4,13 @@
 #
 # SYNOPSIS
 #
-#   AX_EXT
+#   AX_SSE
 #
 # DESCRIPTION
 #
-#   Find supported SIMD extensions by requesting cpuid. When an SIMD
-#   extension is found, the -m"simdextensionname" is added to SIMD_FLAGS if
-#   compiler supports it. For example, if "sse2" is available, then "-msse2"
-#   is added to SIMD_FLAGS.
+#   Find SIMD extensions supported by compiler. The -m"simdextensionname" is
+#   added to SIMD_FLAGS if compiler supports it. For example, if "sse2" is
+#   available, then "-msse2" is added to SIMD_FLAGS.
 #
 #   This macro calls:
 #
@@ -19,7 +18,7 @@
 #
 #   And defines:
 #
-# HAVE_MMX / HAVE_SSE / HAVE_SSE2 / HAVE_SSE3 / HAVE_SSSE3 / HAVE_SSE4.1 / 
HAVE_SSE4.2 / HAVE_AVX
+# HAVE_SSE3 / HAVE_SSE4.1
 #
 # LICENSE
 #

-- 
To view, visit https://gerrit.osmocom.org/2685
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4ce65443c8a33ae9add8f6da9d911c3178472ab2
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] osmo-trx[master]: buildenv: check for __builtin_cpu_supports call support

2017-05-19 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/2689

buildenv: check for __builtin_cpu_supports call support

The '__builtin_cpu_supports' is a GCC's built-in function which
returns a positive integer if the run-time CPU supports specified
SIMD feature and returns 0 otherwise.

This change adds a new check, whether compiler supports this call.
See /gcc/X86-Built-in-Functions.html at gcc.gnu.org for reference.

Change-Id: I797f638573e8c3aae39c28abb157ce2ac419f3f7
---
M configure.ac
1 file changed, 27 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/89/2689/1

diff --git a/configure.ac b/configure.ac
index 7c3c76f..8ddd07d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -120,6 +120,33 @@
 AM_CONDITIONAL(HAVE_SSE4_1, false)
 ])
 
+dnl Check if the compiler supports specified GCC's built-in function
+AC_DEFUN([CHECK_BUILTIN_SUPPORT], [
+  AC_CACHE_CHECK(
+[whether ${CC} has $1 built-in],
+[osmo_cv_cc_has_builtin], [
+  AC_LINK_IFELSE([
+AC_LANG_PROGRAM([], [
+  __builtin_cpu_supports("sse");
+])
+  ],
+  [AS_VAR_SET([osmo_cv_cc_has_builtin], [yes])],
+  [AS_VAR_SET([osmo_cv_cc_has_builtin], [no])])
+]
+  )
+
+  AS_IF([test yes = AS_VAR_GET([osmo_cv_cc_has_builtin])], [
+AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1), 1,
+  [Define to 1 if compiler has the '$1' built-in function])
+  ], [
+AC_MSG_WARN($2)
+  ])
+])
+
+dnl Check if the compiler supports runtime SIMD detection
+CHECK_BUILTIN_SUPPORT([__builtin_cpu_supports],
+  [Runtime SIMD detection will be disabled])
+
 AM_CONDITIONAL(USRP1, [test "x$with_usrp1" = "xyes"])
 AM_CONDITIONAL(ARCH_ARM, [test "x$with_neon" = "xyes" || test 
"x$with_neon_vfpv4" = "xyes"])
 AM_CONDITIONAL(ARCH_ARM_A15, [test "x$with_neon_vfpv4" = "xyes"])

-- 
To view, visit https://gerrit.osmocom.org/2689
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I797f638573e8c3aae39c28abb157ce2ac419f3f7
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] osmo-trx[master]: buildenv: fix build on systems without SIMD support

2017-05-19 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/2687

buildenv: fix build on systems without SIMD support

HAVE_SSE3 and HAVE_SSE4_1 were never defined if CPU architecture
doesn't match the (86*|x86_64*|amd64*) condition.

Change-Id: I3350b14dbc91e9b388d0b04a0ed22ba27d436313
---
M config/ax_sse.m4
1 file changed, 3 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/87/2687/1

diff --git a/config/ax_sse.m4 b/config/ax_sse.m4
index 5c4e321..7d9d7fb 100644
--- a/config/ax_sse.m4
+++ b/config/ax_sse.m4
@@ -40,6 +40,9 @@
 [
   AC_REQUIRE([AC_CANONICAL_HOST])
 
+  AM_CONDITIONAL(HAVE_SSE3, false)
+  AM_CONDITIONAL(HAVE_SSE4_1, false)
+
   case $host_cpu in
 i[[3456]]86*|x86_64*|amd64*)
   AX_CHECK_COMPILE_FLAG(-msse3, ax_cv_support_sse3_ext=yes, [])
@@ -49,7 +52,6 @@
AM_CONDITIONAL(HAVE_SSE3, true)
   else
 AC_MSG_WARN([Your compiler does not support sse3 instructions, can you 
try another compiler?])
-   AM_CONDITIONAL(HAVE_SSE3, false)
   fi
 
   AX_CHECK_COMPILE_FLAG(-msse4.1, ax_cv_support_sse41_ext=yes, [])
@@ -59,7 +61,6 @@
AM_CONDITIONAL(HAVE_SSE4_1, true)
   else
 AC_MSG_WARN([Your compiler does not support sse4.1 instructions, can 
you try another compiler?])
-   AM_CONDITIONAL(HAVE_SSE4_1, false)
   fi
   ;;
   esac

-- 
To view, visit https://gerrit.osmocom.org/2687
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3350b14dbc91e9b388d0b04a0ed22ba27d436313
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


libosmocore[master]: core/conv: add x86 SSE support for Viterbi decoder

2017-05-19 Thread Vadim Yanitskiy

Patch Set 9:

(1 comment)

https://gerrit.osmocom.org/#/c/2454/9/src/viterbi_sse.c
File src/viterbi_sse.c:

PS9, Line 68: M3 = _mm_or_si128(_mm_cmpgt_epi16(M3, M4), _mm_cmpeq_epi16(M3, 
M4));
> Same >= vs > handling that we saw in the non-SSE case. SSE does not provide
Great! Thank you very much again :)


-- 
To view, visit https://gerrit.osmocom.org/2454
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I1da6d71ed0564f1d684f3a836e998d09de5f0351
Gerrit-PatchSet: 9
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Tom Tsou 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: Yes


libosmocore[master]: core/conv: add x86 SSE support for Viterbi decoder

2017-05-19 Thread Tom Tsou

Patch Set 9:

(1 comment)

https://gerrit.osmocom.org/#/c/2454/9/src/viterbi_sse.c
File src/viterbi_sse.c:

PS9, Line 68: M3 = _mm_or_si128(_mm_cmpgt_epi16(M3, M4), _mm_cmpeq_epi16(M3, 
M4));
Same >= vs > handling that we saw in the non-SSE case. SSE does not provide a 
signed 16-bit integer greater than or equal to instruction, so we use this 
chained combination.


-- 
To view, visit https://gerrit.osmocom.org/2454
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I1da6d71ed0564f1d684f3a836e998d09de5f0351
Gerrit-PatchSet: 9
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Tom Tsou 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: Yes


[PATCH] libosmocore[master]: core/conv: add x86 SSE support for Viterbi decoder

2017-05-19 Thread Tom Tsou
Hello Vadim Yanitskiy, Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2454

to look at the new patch set (#9).

core/conv: add x86 SSE support for Viterbi decoder

Fast convolutional decoding is provided through x86 intrinsic based
SSE operations. SSE3, found on virtually all modern x86 processors,
is the minimal requirement. SSE4.1 and AVX2 are used if available.

Also, the original code was extended with runtime SIMD detection,
so only supported extensions will be used by target CPU. It makes
the library more partable, what is very important for binary
packages distribution. Runtime SIMD detection is currently
implemented through the __builtin_cpu_supports call.

Change-Id: I1da6d71ed0564f1d684f3a836e998d09de5f0351
---
M src/Makefile.am
M src/viterbi.c
M src/viterbi_gen.c
A src/viterbi_sse.c
4 files changed, 748 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/54/2454/9

diff --git a/src/Makefile.am b/src/Makefile.am
index 6948e1a..e8e67ef 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -19,6 +19,12 @@
 macaddr.c stat_item.c stats.c stats_statsd.c prim.c \
 viterbi.c viterbi_gen.c
 
+if HAVE_SSE3
+libosmocore_la_SOURCES += viterbi_sse.c
+# Per-object flags hack
+viterbi_sse.lo : CFLAGS += $(SIMD_FLAGS)
+endif
+
 BUILT_SOURCES = crc8gen.c crc16gen.c crc32gen.c crc64gen.c
 
 if ENABLE_PLUGIN
diff --git a/src/viterbi.c b/src/viterbi.c
index 21c6a57..2097a02 100644
--- a/src/viterbi.c
+++ b/src/viterbi.c
@@ -24,11 +24,34 @@
 #include 
 #include 
 
-#include 
 #include "config.h"
+
+#include 
 
 #define BIT2NRZ(REG,N) (((REG >> N) & 0x01) * 2 - 1) * -1
 #define NUM_STATES(K)  (K == 7 ? 64 : 16)
+
+static int init_complete = 0;
+
+__attribute__ ((visibility("hidden"))) int avx2_supported = 0;
+__attribute__ ((visibility("hidden"))) int sse3_supported = 0;
+__attribute__ ((visibility("hidden"))) int sse41_supported = 0;
+
+/**
+ * This pointers will be initialized by the osmo_conv_init()
+ * depending on supported SIMD extensions.
+ */
+static int16_t *(*vdec_malloc)(size_t n);
+static void (*vdec_free)(int16_t *ptr);
+
+/* Forward malloc wrappers */
+int16_t *osmo_conv_vdec_malloc(size_t n);
+void osmo_conv_vdec_free(int16_t *ptr);
+
+#ifdef HAVE_SSE3
+int16_t *osmo_conv_vdec_malloc_sse3(size_t n);
+void osmo_conv_vdec_free_sse3(int16_t *ptr);
+#endif
 
 /* Forward Metric Units */
 void osmo_conv_gen_metrics_k5_n2(const int8_t *seq, const int16_t *out,
@@ -43,6 +66,21 @@
int16_t *sums, int16_t *paths, int norm);
 void osmo_conv_gen_metrics_k7_n4(const int8_t *seq, const int16_t *out,
int16_t *sums, int16_t *paths, int norm);
+
+#ifdef HAVE_SSE3
+void osmo_conv_gen_metrics_k5_n2_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k5_n3_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k5_n4_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k7_n2_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k7_n3_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k7_n4_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+#endif
 
 /* Trellis State
  * state - Internal lshift register value
@@ -89,12 +127,6 @@
void (*metric_func)(const int8_t *, const int16_t *,
int16_t *, int16_t *, int);
 };
-
-/* Non-aligned Memory Allocator */
-static int16_t *vdec_malloc(size_t n)
-{
-   return (int16_t *) malloc(sizeof(int16_t) * n);
-}
 
 /* Accessor calls */
 static inline int conv_code_recursive(const struct osmo_conv_code *code)
@@ -294,9 +326,9 @@
if (!trellis)
return;
 
+   vdec_free(trellis->outputs);
+   vdec_free(trellis->sums);
free(trellis->vals);
-   free(trellis->outputs);
-   free(trellis->sums);
free(trellis);
 }
 
@@ -430,7 +462,7 @@
if (!dec)
return;
 
-   free(dec->paths[0]);
+   vdec_free(dec->paths[0]);
free(dec->paths);
free_trellis(dec->trellis);
free(dec);
@@ -456,13 +488,31 @@
if (dec->k == 5) {
switch (dec->n) {
case 2:
+   #ifdef HAVE_SSE3
+   dec->metric_func = !sse3_supported ?
+   osmo_conv_gen_metrics_k5_n2 :
+   osmo_conv_gen_metrics_k5_n2_sse;
+   #else
dec->metric_func = osmo_conv_gen_metrics_k5_n2;
+   #endif
break;
case 3:
+   #ifdef HAVE_SSE3
+   

[PATCH] libosmocore[master]: core/conv: add x86 SSE support for Viterbi decoder

2017-05-19 Thread Tom Tsou
Hello Vadim Yanitskiy, Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2454

to look at the new patch set (#8).

core/conv: add x86 SSE support for Viterbi decoder

Fast convolutional decoding is provided through x86 intrinsic based
SSE operations. SSE3, found on virtually all modern x86 processors,
is the minimal requirement. SSE4.1 and AVX2 are used if available.

Also, the original code was extended with runtime SIMD detection,
so only supported extensions will be used by target CPU. It makes
the library more partable, what is very important for binary
packages distribution. Runtime SIMD detection is currently
implemented through the __builtin_cpu_supports call.

Change-Id: I1da6d71ed0564f1d684f3a836e998d09de5f0351
---
M src/Makefile.am
M src/viterbi.c
M src/viterbi_gen.c
A src/viterbi_sse.c
4 files changed, 748 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/54/2454/8

diff --git a/src/Makefile.am b/src/Makefile.am
index 6948e1a..e8e67ef 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -19,6 +19,12 @@
 macaddr.c stat_item.c stats.c stats_statsd.c prim.c \
 viterbi.c viterbi_gen.c
 
+if HAVE_SSE3
+libosmocore_la_SOURCES += viterbi_sse.c
+# Per-object flags hack
+viterbi_sse.lo : CFLAGS += $(SIMD_FLAGS)
+endif
+
 BUILT_SOURCES = crc8gen.c crc16gen.c crc32gen.c crc64gen.c
 
 if ENABLE_PLUGIN
diff --git a/src/viterbi.c b/src/viterbi.c
index 21c6a57..2097a02 100644
--- a/src/viterbi.c
+++ b/src/viterbi.c
@@ -24,11 +24,34 @@
 #include 
 #include 
 
-#include 
 #include "config.h"
+
+#include 
 
 #define BIT2NRZ(REG,N) (((REG >> N) & 0x01) * 2 - 1) * -1
 #define NUM_STATES(K)  (K == 7 ? 64 : 16)
+
+static int init_complete = 0;
+
+__attribute__ ((visibility("hidden"))) int avx2_supported = 0;
+__attribute__ ((visibility("hidden"))) int sse3_supported = 0;
+__attribute__ ((visibility("hidden"))) int sse41_supported = 0;
+
+/**
+ * This pointers will be initialized by the osmo_conv_init()
+ * depending on supported SIMD extensions.
+ */
+static int16_t *(*vdec_malloc)(size_t n);
+static void (*vdec_free)(int16_t *ptr);
+
+/* Forward malloc wrappers */
+int16_t *osmo_conv_vdec_malloc(size_t n);
+void osmo_conv_vdec_free(int16_t *ptr);
+
+#ifdef HAVE_SSE3
+int16_t *osmo_conv_vdec_malloc_sse3(size_t n);
+void osmo_conv_vdec_free_sse3(int16_t *ptr);
+#endif
 
 /* Forward Metric Units */
 void osmo_conv_gen_metrics_k5_n2(const int8_t *seq, const int16_t *out,
@@ -43,6 +66,21 @@
int16_t *sums, int16_t *paths, int norm);
 void osmo_conv_gen_metrics_k7_n4(const int8_t *seq, const int16_t *out,
int16_t *sums, int16_t *paths, int norm);
+
+#ifdef HAVE_SSE3
+void osmo_conv_gen_metrics_k5_n2_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k5_n3_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k5_n4_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k7_n2_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k7_n3_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+void osmo_conv_gen_metrics_k7_n4_sse(const int8_t *seq, const int16_t *out,
+   int16_t *sums, int16_t *paths, int norm);
+#endif
 
 /* Trellis State
  * state - Internal lshift register value
@@ -89,12 +127,6 @@
void (*metric_func)(const int8_t *, const int16_t *,
int16_t *, int16_t *, int);
 };
-
-/* Non-aligned Memory Allocator */
-static int16_t *vdec_malloc(size_t n)
-{
-   return (int16_t *) malloc(sizeof(int16_t) * n);
-}
 
 /* Accessor calls */
 static inline int conv_code_recursive(const struct osmo_conv_code *code)
@@ -294,9 +326,9 @@
if (!trellis)
return;
 
+   vdec_free(trellis->outputs);
+   vdec_free(trellis->sums);
free(trellis->vals);
-   free(trellis->outputs);
-   free(trellis->sums);
free(trellis);
 }
 
@@ -430,7 +462,7 @@
if (!dec)
return;
 
-   free(dec->paths[0]);
+   vdec_free(dec->paths[0]);
free(dec->paths);
free_trellis(dec->trellis);
free(dec);
@@ -456,13 +488,31 @@
if (dec->k == 5) {
switch (dec->n) {
case 2:
+   #ifdef HAVE_SSE3
+   dec->metric_func = !sse3_supported ?
+   osmo_conv_gen_metrics_k5_n2 :
+   osmo_conv_gen_metrics_k5_n2_sse;
+   #else
dec->metric_func = osmo_conv_gen_metrics_k5_n2;
+   #endif
break;
case 3:
+   #ifdef HAVE_SSE3
+   

[MERGED] osmo-trx[master]: radioInterface: Remove UmTRX 'diversity' option

2017-05-19 Thread Tom Tsou
Tom Tsou has submitted this change and it was merged.

Change subject: radioInterface: Remove UmTRX 'diversity' option
..


radioInterface: Remove UmTRX 'diversity' option

The 'diversity' option was an experimental 2 antenna receiver
implementation for UmTRX. The implementation has not been
maintained and current working status is unknown.

In addition to code rot, Coverity is triggering errors in the
associated code sections.

Removal of code cleans up many cases of special handling that
were necessary to accommodate the implementation.

Change-Id: I46752ccf5dbcffbec806081dec03e69a0fbdcdb7
---
M Transceiver52M/Makefile.am
M Transceiver52M/UHDDevice.cpp
M Transceiver52M/USRPDevice.cpp
M Transceiver52M/osmo-trx.cpp
M Transceiver52M/radioDevice.h
M Transceiver52M/radioInterface.cpp
M Transceiver52M/radioInterface.h
D Transceiver52M/radioInterfaceDiversity.cpp
M Transceiver52M/sigProcLib.cpp
9 files changed, 16 insertions(+), 406 deletions(-)

Approvals:
  Tom Tsou: Looks good to me, approved
  Harald Welte: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/Transceiver52M/Makefile.am b/Transceiver52M/Makefile.am
index 68cdf74..c2ab9ca 100644
--- a/Transceiver52M/Makefile.am
+++ b/Transceiver52M/Makefile.am
@@ -67,8 +67,7 @@
$(COMMON_SOURCES) \
Resampler.cpp \
radioInterfaceResamp.cpp \
-   radioInterfaceMulti.cpp \
-   radioInterfaceDiversity.cpp
+   radioInterfaceMulti.cpp
 
 bin_PROGRAMS = osmo-trx
 
diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp
index c5ea4c1..ce6d1be 100644
--- a/Transceiver52M/UHDDevice.cpp
+++ b/Transceiver52M/UHDDevice.cpp
@@ -139,16 +139,6 @@
 #define NUM_UHD_OFFSETS (sizeof(uhd_offsets)/sizeof(uhd_offsets[0]))
 
 /*
- * Offset handling for special cases. Currently used for UmTRX dual channel
- * diversity receiver only.
- */
-static struct uhd_dev_offset special_offsets[] = {
-   { UMTRX, 1, 1, 8.0875e-5, "UmTRX diversity, 1 SPS" },
-   { UMTRX, 4, 1, 5.2103e-5, "UmTRX diversity, 4 SPS" },
-};
-
-
-/*
  * Select sample rate based on device type and requested samples-per-symbol.
  * The base rate is either GSM symbol rate, 270.833 kHz, or the minimum
  * usable channel spacing of 400 kHz.
@@ -156,15 +146,6 @@
 static double select_rate(uhd_dev_type type, int sps,
  RadioDevice::InterfaceType iface)
 {
-   if (iface == RadioDevice::DIVERSITY) {
-   if (type == UMTRX)
-   return GSMRATE * 4;
-
-   LOG(ALERT) << "Diversity supported on UmTRX only";
-   return -.99;
-   }
-
-
if ((sps != 4) && (sps != 1))
return -.99;
 
@@ -499,30 +480,13 @@
return 0.0;
}
 
-   /* Special cases (e.g. diversity receiver) */
-   if (iface == DIVERSITY) {
-   if ((dev_type != UMTRX) || (rx_sps != 1)) {
-   LOG(ALERT) << "Unsupported device configuration";
-   return 0.0;
-   }
-
-   switch (tx_sps) {
-   case 1:
-   offset = _offsets[0];
+   /* Search for matching offset value */
+   for (size_t i = 0; i < NUM_UHD_OFFSETS; i++) {
+   if ((dev_type == uhd_offsets[i].type) &&
+   (tx_sps == uhd_offsets[i].tx_sps) &&
+   (rx_sps == uhd_offsets[i].rx_sps)) {
+   offset = _offsets[i];
break;
-   case 4:
-   default:
-   offset = _offsets[1];
-   }
-   } else {
-   /* Search for matching offset value */
-   for (size_t i = 0; i < NUM_UHD_OFFSETS; i++) {
-   if ((dev_type == uhd_offsets[i].type) &&
-   (tx_sps == uhd_offsets[i].tx_sps) &&
-   (rx_sps == uhd_offsets[i].rx_sps)) {
-   offset = _offsets[i];
-   break;
-   }
}
}
 
@@ -860,9 +824,6 @@
double _rx_rate = select_rate(dev_type, rx_sps, iface);
double _tx_rate = select_rate(dev_type, tx_sps, iface);
 
-   if (iface == DIVERSITY)
-   _rx_rate = select_rate(dev_type, 1, iface);
-
if ((_tx_rate < 0.0) || (_rx_rate < 0.0))
return -1;
if (set_rates(_tx_rate, _rx_rate) < 0)
@@ -873,8 +834,7 @@
// Setting LMS6002D LPF to 500kHz gives us the best signal 
quality
for (size_t i = 0; i < chans; i++) {
usrp_dev->set_tx_bandwidth(500*1000*2, i);
-   if (iface != DIVERSITY)
-   usrp_dev->set_rx_bandwidth(500*1000*2, i);
+   usrp_dev->set_rx_bandwidth(500*1000*2, i);
}
} 

[MERGED] osmo-trx[master]: debian: remove obsolete dependency

2017-05-19 Thread Tom Tsou
Tom Tsou has submitted this change and it was merged.

Change subject: debian: remove obsolete dependency
..


debian: remove obsolete dependency

This should fix package build for Ubuntu 17.04: obsolete package
hardening-wrapper was removed which cause .deb build failure.
The dependency on it is incorrect to begin with because we use
DEB_BUILD_MAINT_OPTIONS instead.

Change-Id: I3ea72b4123a280a846086d083c4f3189d611f8cf
---
M debian/control
1 file changed, 0 insertions(+), 1 deletion(-)

Approvals:
  Tom Tsou: Looks good to me, approved
  Harald Welte: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/debian/control b/debian/control
index 151aa92..0e3b714 100644
--- a/debian/control
+++ b/debian/control
@@ -12,7 +12,6 @@
libuhd-dev,
libusb-1.0-0-dev,
libboost-all-dev,
-   hardening-wrapper,
libfftw3-dev
 Standards-Version: 3.9.6
 Vcs-Browser: http://cgit.osmocom.org/osmo-trx

-- 
To view, visit https://gerrit.osmocom.org/2400
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3ea72b4123a280a846086d083c4f3189d611f8cf
Gerrit-PatchSet: 4
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Tom Tsou 
Gerrit-Reviewer: neels 


osmo-trx[master]: debian: remove obsolete dependency

2017-05-19 Thread Tom Tsou

Patch Set 3: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/2400
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I3ea72b4123a280a846086d083c4f3189d611f8cf
Gerrit-PatchSet: 3
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Tom Tsou 
Gerrit-Reviewer: neels 
Gerrit-HasComments: No


osmo-trx[master]: radioInterface: Remove UmTRX 'diversity' option

2017-05-19 Thread Tom Tsou

Patch Set 4: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/2186
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I46752ccf5dbcffbec806081dec03e69a0fbdcdb7
Gerrit-PatchSet: 4
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Tom Tsou 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Tom Tsou 
Gerrit-HasComments: No


[MERGED] osmo-trx[master]: cosmetic: Add info about SSE support

2017-05-19 Thread Tom Tsou
Tom Tsou has submitted this change and it was merged.

Change subject: cosmetic: Add info about SSE support
..


cosmetic: Add info about SSE support

The osmo-trx binary outputs no info about its SSE support status.
This commits adds some putput that informs about the SSE of the
binary and also tells which of the SSE levels the CPU supports.

Change-Id: Iacc83fd668c31644e0efb3e18962cf2870ed1daf
---
M Transceiver52M/osmo-trx.cpp
1 file changed, 16 insertions(+), 0 deletions(-)

Approvals:
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Tom Tsou: Looks good to me, approved
  Harald Welte: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp
index 2d35a60..4a10bbe 100644
--- a/Transceiver52M/osmo-trx.cpp
+++ b/Transceiver52M/osmo-trx.cpp
@@ -427,6 +427,22 @@
RadioDevice::InterfaceType iface = RadioDevice::NORMAL;
struct trx_config config;
 
+#ifdef HAVE_SSE3
+   printf("Info: SSE3 support compiled in");
+   if (__builtin_cpu_supports("sse3"))
+   printf(" and supported by CPU\n");
+   else
+   printf(", but not supported by CPU\n");
+#endif
+
+#ifdef HAVE_SSE4_1
+   printf("Info: SSE4.1 support compiled in");
+   if (__builtin_cpu_supports("sse4.1"))
+   printf(" and supported by CPU\n");
+   else
+   printf(", but not supported by CPU\n");
+#endif
+
convolve_init();
convert_init();
 

-- 
To view, visit https://gerrit.osmocom.org/2101
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iacc83fd668c31644e0efb3e18962cf2870ed1daf
Gerrit-PatchSet: 4
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Tom Tsou 
Gerrit-Reviewer: Vadim Yanitskiy 


[MERGED] osmo-trx[master]: buildenv: Split up SSE3 and SSE4.1 code

2017-05-19 Thread Tom Tsou
Tom Tsou has submitted this change and it was merged.

Change subject: buildenv: Split up SSE3 and SSE4.1 code
..


buildenv: Split up SSE3 and SSE4.1 code

Currently we find SSE3 and SSE4.1 code mixed togehter along with
generic code in one file. This introduces the risk that the
compiler exidantly mixes SSE4.1 instructions into an SSE3, or
even worse into a generic code path.

This commit splits the SSE3 and SSE4.1 code into separate files
and compiles them with the matching target options.

Change-Id: I846e190e92f1258cd412d1b2d79b539e204e04b3
---
M Transceiver52M/x86/Makefile.am
M Transceiver52M/x86/convert.c
A Transceiver52M/x86/convert_sse_3.c
A Transceiver52M/x86/convert_sse_3.h
A Transceiver52M/x86/convert_sse_4_1.c
A Transceiver52M/x86/convert_sse_4_1.h
M Transceiver52M/x86/convolve.c
A Transceiver52M/x86/convolve_sse_3.c
A Transceiver52M/x86/convolve_sse_3.h
R config/ax_sse.m4
M configure.ac
M utils/convolvetest/Makefile
12 files changed, 893 insertions(+), 661 deletions(-)

Approvals:
  Tom Tsou: Looks good to me, approved
  Neels Hofmeyr: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, but someone else must approve
  Jenkins Builder: Verified

Objections:
  Vadim Yanitskiy: I would prefer this is not merged as is



diff --git a/Transceiver52M/x86/Makefile.am b/Transceiver52M/x86/Makefile.am
index 7a0b75f..45aa629 100644
--- a/Transceiver52M/x86/Makefile.am
+++ b/Transceiver52M/x86/Makefile.am
@@ -1,7 +1,28 @@
 if !ARCH_ARM
-AM_CFLAGS = -Wall -std=gnu99 $(SIMD_FLAGS) -I${srcdir}/../common
+AM_CFLAGS = -Wall -std=gnu99 -I${srcdir}/../common
 
 noinst_LTLIBRARIES = libarch.la
+noinst_LTLIBRARIES += libarch_sse_3.la
+noinst_LTLIBRARIES += libarch_sse_4_1.la
+
+libarch_la_LIBADD =
+
+# SSE 3 specific code
+if HAVE_SSE3
+libarch_sse_3_la_SOURCES = \
+   convert_sse_3.c \
+   convolve_sse_3.c
+libarch_sse_3_la_CFLAGS = $(AM_CFLAGS) -msse3
+libarch_la_LIBADD += libarch_sse_3.la
+endif
+
+# SSE 4.1 specific code
+if HAVE_SSE4_1
+libarch_sse_4_1_la_SOURCES = \
+   convert_sse_4_1.c
+libarch_sse_4_1_la_CFLAGS = $(AM_CFLAGS) -msse4.1
+libarch_la_LIBADD += libarch_sse_4_1.la
+endif
 
 libarch_la_SOURCES = \
../common/convolve_base.c \
diff --git a/Transceiver52M/x86/convert.c b/Transceiver52M/x86/convert.c
index 3f76b65..db98050 100644
--- a/Transceiver52M/x86/convert.c
+++ b/Transceiver52M/x86/convert.c
@@ -20,6 +20,8 @@
 #include 
 #include 
 #include "convert.h"
+#include "convert_sse_3.h"
+#include "convert_sse_4_1.h"
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -35,140 +37,6 @@
 };
 
 static struct convert_cpu_context c;
-
-#ifdef HAVE_SSE3
-#include 
-#include 
-
-#ifdef HAVE_SSE4_1
-#include 
-
-/* 16*N 16-bit signed integer converted to single precision floats */
-static void _sse_convert_si16_ps_16n(float *restrict out,
-const short *restrict in,
-int len)
-{
-   __m128i m0, m1, m2, m3, m4, m5;
-   __m128 m6, m7, m8, m9;
-
-   for (int i = 0; i < len / 16; i++) {
-   /* Load (unaligned) packed floats */
-   m0 = _mm_loadu_si128((__m128i *) [16 * i + 0]);
-   m1 = _mm_loadu_si128((__m128i *) [16 * i + 8]);
-
-   /* Unpack */
-   m2 = _mm_cvtepi16_epi32(m0);
-   m4 = _mm_cvtepi16_epi32(m1);
-   m0 = _mm_shuffle_epi32(m0, _MM_SHUFFLE(1, 0, 3, 2));
-   m1 = _mm_shuffle_epi32(m1, _MM_SHUFFLE(1, 0, 3, 2));
-   m3 = _mm_cvtepi16_epi32(m0);
-   m5 = _mm_cvtepi16_epi32(m1);
-
-   /* Convert */
-   m6 = _mm_cvtepi32_ps(m2);
-   m7 = _mm_cvtepi32_ps(m3);
-   m8 = _mm_cvtepi32_ps(m4);
-   m9 = _mm_cvtepi32_ps(m5);
-
-   /* Store */
-   _mm_storeu_ps([16 * i + 0], m6);
-   _mm_storeu_ps([16 * i + 4], m7);
-   _mm_storeu_ps([16 * i + 8], m8);
-   _mm_storeu_ps([16 * i + 12], m9);
-   }
-}
-
-/* 16*N 16-bit signed integer conversion with remainder */
-static void _sse_convert_si16_ps(float *restrict out,
-const short *restrict in,
-int len)
-{
-   int start = len / 16 * 16;
-
-   _sse_convert_si16_ps_16n(out, in, len);
-
-   for (int i = 0; i < len % 16; i++)
-   out[start + i] = in[start + i];
-}
-#endif /* HAVE_SSE4_1 */
-
-/* 8*N single precision floats scaled and converted to 16-bit signed integer */
-static void _sse_convert_scale_ps_si16_8n(short *restrict out,
- const float *restrict in,
- float scale, int len)
-{
-   __m128 m0, m1, m2;
-   __m128i m4, m5;
-
-   for (int i = 0; i < len / 8; i++) {
-   /* Load (unaligned) packed floats */
-   m0 = 

[MERGED] osmo-trx[master]: buildenv: Make build CPU invariant

2017-05-19 Thread Tom Tsou
Tom Tsou has submitted this change and it was merged.

Change subject: buildenv: Make build CPU invariant
..


buildenv: Make build CPU invariant

Currently the build environment checks which extension the current
CPU supports and picks the compiler flags accordingly.

If the build is happening on a machine that does not support the
extensions we need (SSE3, SSE4.1), the binary will lack those
extensions, even if its intended to be used on a more powerful
machine that would support the extensions.

This commit removes the CPU tests from the build process.

Change-Id: Ic913aa13c23c348ae62e78c9dfd6ed8b0a62798c
---
M config/ax_ext.m4
1 file changed, 16 insertions(+), 166 deletions(-)

Approvals:
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Tom Tsou: Looks good to me, approved
  Harald Welte: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/config/ax_ext.m4 b/config/ax_ext.m4
index fbd10cc..4883b89 100644
--- a/config/ax_ext.m4
+++ b/config/ax_ext.m4
@@ -30,6 +30,10 @@
 #   permitted in any medium without royalty provided the copyright notice
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
+#
+# NOTE: The functionality that requests the cpuid has been stripped because
+#   this project detects the CPU capabilities during runtime. However, we
+#   still need to check if the compiler supports the requested SIMD flag
 
 #serial 12
 
@@ -44,176 +48,22 @@
   AC_REQUIRE([AX_GCC_X86_AVX_XGETBV])
 
   AX_GCC_X86_CPUID(0x0001)
-  ecx=`echo $ax_cv_gcc_x86_cpuid_0x0001 | cut -d ":" -f 3`
-  edx=`echo $ax_cv_gcc_x86_cpuid_0x0001 | cut -d ":" -f 4`
 
-  AC_CACHE_CHECK([whether mmx is supported], [ax_cv_have_mmx_ext],
-  [
-ax_cv_have_mmx_ext=no
-if test "$((0x$edx>>23&0x01))" = 1; then
-  ax_cv_have_mmx_ext=yes
-fi
-  ])
-
-  AC_CACHE_CHECK([whether sse is supported], [ax_cv_have_sse_ext],
-  [
-ax_cv_have_sse_ext=no
-if test "$((0x$edx>>25&0x01))" = 1; then
-  ax_cv_have_sse_ext=yes
-fi
-  ])
-
-  AC_CACHE_CHECK([whether sse2 is supported], [ax_cv_have_sse2_ext],
-  [
-ax_cv_have_sse2_ext=no
-if test "$((0x$edx>>26&0x01))" = 1; then
-  ax_cv_have_sse2_ext=yes
-fi
-  ])
-
-  AC_CACHE_CHECK([whether sse3 is supported], [ax_cv_have_sse3_ext],
-  [
-ax_cv_have_sse3_ext=no
-if test "$((0x$ecx&0x01))" = 1; then
-  ax_cv_have_sse3_ext=yes
-fi
-  ])
-
-  AC_CACHE_CHECK([whether ssse3 is supported], [ax_cv_have_ssse3_ext],
-  [
-ax_cv_have_ssse3_ext=no
-if test "$((0x$ecx>>9&0x01))" = 1; then
-  ax_cv_have_ssse3_ext=yes
-fi
-  ])
-
-  AC_CACHE_CHECK([whether sse4.1 is supported], [ax_cv_have_sse41_ext],
-  [
-ax_cv_have_sse41_ext=no
-if test "$((0x$ecx>>19&0x01))" = 1; then
-  ax_cv_have_sse41_ext=yes
-fi
-  ])
-
-  AC_CACHE_CHECK([whether sse4.2 is supported], [ax_cv_have_sse42_ext],
-  [
-ax_cv_have_sse42_ext=no
-if test "$((0x$ecx>>20&0x01))" = 1; then
-  ax_cv_have_sse42_ext=yes
-fi
-  ])
-
-  AC_CACHE_CHECK([whether avx is supported by processor], 
[ax_cv_have_avx_cpu_ext],
-  [
-ax_cv_have_avx_cpu_ext=no
-if test "$((0x$ecx>>28&0x01))" = 1; then
-  ax_cv_have_avx_cpu_ext=yes
-fi
-  ])
-
-  if test x"$ax_cv_have_avx_cpu_ext" = x"yes"; then
-AX_GCC_X86_AVX_XGETBV(0x)
-
-xgetbv_eax="0"
-if test x"$ax_cv_gcc_x86_avx_xgetbv_0x" != x"unknown"; then
-  xgetbv_eax=`echo $ax_cv_gcc_x86_avx_xgetbv_0x | cut -d ":" 
-f 1`
-fi
-
-AC_CACHE_CHECK([whether avx is supported by operating system], 
[ax_cv_have_avx_ext],
-[
-  ax_cv_have_avx_ext=no
-
-  if test "$((0x$ecx>>27&0x01))" = 1; then
-if test "$((0x$xgetbv_eax&0x6))" = 6; then
-  ax_cv_have_avx_ext=yes
-fi
-  fi
-])
-if test x"$ax_cv_have_avx_ext" = x"no"; then
-  AC_MSG_WARN([Your processor supports AVX, but your operating system 
doesn't])
-fi
+  AX_CHECK_COMPILE_FLAG(-msse3, ax_cv_support_sse3_ext=yes, [])
+  if test x"$ax_cv_support_sse3_ext" = x"yes"; then
+SIMD_FLAGS="$SIMD_FLAGS -msse3"
+AC_DEFINE(HAVE_SSE3,,[Support SSE3 (Streaming SIMD Extensions 3) 
instructions])
+  else
+AC_MSG_WARN([Your compiler does not support sse3 instructions, can you 
try another compiler?])
   fi
 
-  if test "$ax_cv_have_mmx_ext" = yes; then
-AX_CHECK_COMPILE_FLAG(-mmmx, ax_cv_support_mmx_ext=yes, [])
-if test x"$ax_cv_support_mmx_ext" = x"yes"; then
-  SIMD_FLAGS="$SIMD_FLAGS -mmmx"
-  

[MERGED] osmo-trx[master]: cosmetic: remove code duplication

2017-05-19 Thread Tom Tsou
Tom Tsou has submitted this change and it was merged.

Change subject: cosmetic: remove code duplication
..


cosmetic: remove code duplication

The ARM and the X86 implementation of the conversion functions share
the same, non cpu specific implementation in separate files.

This commit removes the code duplication by putting the generic
implementation into a convert_base.c, similar to to convolve_base.c

Change-Id: Ic8d8534a343e27cde79ddc85be4998ebd0cb6e5c
---
M Transceiver52M/arm/convert.c
M Transceiver52M/common/convert.h
A Transceiver52M/common/convert_base.c
M Transceiver52M/x86/Makefile.am
M Transceiver52M/x86/convert.c
5 files changed, 49 insertions(+), 35 deletions(-)

Approvals:
  Tom Tsou: Looks good to me, approved
  Max: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/Transceiver52M/arm/convert.c b/Transceiver52M/arm/convert.c
index e489d22..57796ea 100644
--- a/Transceiver52M/arm/convert.c
+++ b/Transceiver52M/arm/convert.c
@@ -28,19 +28,6 @@
 void neon_convert_ps_si16_4n(short *, const float *, const float *, int);
 void neon_convert_si16_ps_4n(float *, const short *, int);
 
-#ifndef HAVE_NEON
-static void convert_si16_ps(float *out, const short *in, int len)
-{
-   for (int i = 0; i < len; i++)
-   out[i] = in[i];
-}
-
-static void convert_ps_si16(short *out, const float *in, float scale, int len)
-{
-   for (int i = 0; i < len; i++)
-   out[i] = in[i] * scale;
-}
-#else
 /* 4*N 16-bit signed integer conversion with remainder */
 static void neon_convert_si16_ps(float *out,
 const short *in,
@@ -79,7 +66,7 @@
else
neon_convert_ps_si16_4n(out, in, q, len >> 2);
 #else
-   convert_ps_si16(out, in, scale, len);
+   base_convert_float_short(out, in, scale, len);
 #endif
 }
 
@@ -91,6 +78,6 @@
else
neon_convert_si16_ps_4n(out, in, len >> 2);
 #else
-   convert_si16_ps(out, in, len);
+   base_convert_short_float(out, in, len);
 #endif
 }
diff --git a/Transceiver52M/common/convert.h b/Transceiver52M/common/convert.h
index 1d3a180..73402b0 100644
--- a/Transceiver52M/common/convert.h
+++ b/Transceiver52M/common/convert.h
@@ -2,7 +2,14 @@
 #define _CONVERT_H_
 
 void convert_float_short(short *out, const float *in, float scale, int len);
+
 void convert_short_float(float *out, const short *in, int len);
+
+void base_convert_float_short(short *out, const float *in,
+ float scale, int len);
+
+void base_convert_short_float(float *out, const short *in, int len);
+
 void convert_init(void);
 
 #endif /* _CONVERT_H_ */
diff --git a/Transceiver52M/common/convert_base.c 
b/Transceiver52M/common/convert_base.c
new file mode 100644
index 000..5251fb8
--- /dev/null
+++ b/Transceiver52M/common/convert_base.c
@@ -0,0 +1,34 @@
+/*
+ * Conversion
+ * Copyright (C) 2012, 2013 Thomas Tsou 
+ *
+ * This library 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 library is distributed in the hope that 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "convert.h"
+
+void base_convert_float_short(short *out, const float *in,
+ float scale, int len)
+{
+   for (int i = 0; i < len; i++)
+   out[i] = in[i] * scale;
+}
+
+void base_convert_short_float(float *out, const short *in, int len)
+{
+   for (int i = 0; i < len; i++)
+   out[i] = in[i];
+}
+
diff --git a/Transceiver52M/x86/Makefile.am b/Transceiver52M/x86/Makefile.am
index 699faad..7a0b75f 100644
--- a/Transceiver52M/x86/Makefile.am
+++ b/Transceiver52M/x86/Makefile.am
@@ -5,6 +5,7 @@
 
 libarch_la_SOURCES = \
../common/convolve_base.c \
+   ../common/convert_base.c \
convert.c \
convolve.c
 endif
diff --git a/Transceiver52M/x86/convert.c b/Transceiver52M/x86/convert.c
index db1c0fc..3f76b65 100644
--- a/Transceiver52M/x86/convert.c
+++ b/Transceiver52M/x86/convert.c
@@ -170,28 +170,13 @@
 }
 #endif
 
-__attribute__((optimize("no-tree-vectorize")))
-static void convert_scale_ps_si16(short *out, const float *in,
- float scale, int len)
-{
-   for (int i = 0; i < len; i++)
-   out[i] = 

[MERGED] osmo-trx[master]: Add test program to verify convolution implementation

2017-05-19 Thread Tom Tsou
Tom Tsou has submitted this change and it was merged.

Change subject: Add test program to verify convolution implementation
..


Add test program to verify convolution implementation

Convolution is a complex process and we should be able to verify
if computing results change when the implementation is touched.

This commit adds a test program that executes some testcases.
The testcases are crafted in a way that every implmentation
(several different ones for SSE) is executed once. The output
can be compared against the included .ok file.

Change-Id: Ic702ecb356c652fbcd76bee689717fb5d3526fe9
---
A utils/convolvetest/Makefile
A utils/convolvetest/convtest.ok
A utils/convolvetest/main.c
3 files changed, 238 insertions(+), 0 deletions(-)

Approvals:
  Tom Tsou: Looks good to me, approved
  Harald Welte: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/utils/convolvetest/Makefile b/utils/convolvetest/Makefile
new file mode 100644
index 000..0ce4cb1
--- /dev/null
+++ b/utils/convolvetest/Makefile
@@ -0,0 +1,16 @@
+all: main.o convolve_base.o convolve.o
+   gcc -g -Wall ./*.o -o convtest -losmocore
+
+clean:
+   rm -f ./*.o
+   rm -f ./convtest
+
+main.o: main.c
+   gcc -g -Wall -c main.c
+
+convolve_base.o: ../../Transceiver52M/common/convolve_base.c
+   gcc -std=c99 -c ../../Transceiver52M/common/convolve_base.c
+
+convolve.o: ../../Transceiver52M/x86/convolve.c
+   gcc -std=c99 -c ../../Transceiver52M/x86/convolve.c -I 
../../Transceiver52M/common/ -msse3 -DHAVE_SSE3
+
diff --git a/utils/convolvetest/convtest.ok b/utils/convolvetest/convtest.ok
new file mode 100644
index 000..5766252
--- /dev/null
+++ b/utils/convolvetest/convtest.ok
@@ -0,0 +1,72 @@
+ TEST COMPLEX BASE IMPLEMENTATION 
+float x[] = 
{0.828957,0.675654,0.904170,0.191112,0.394521,0.706067,0.868924,0.547397,0.738959,0.932485,0.233119,0.926576,0.551443,0.933420,0.494407,0.552568,0.939129,0.799646,0.814139,0.594497,0.657201,0.995300,0.935852,0.324541,0.874309,0.589157,0.637771,0.759324,0.775421,0.794910,0.262785,0.604379,0.470564,0.166955}
+
+float h[] = 
{0.726144,0.746635,0.470674,0.211604,0.963092,0.264553,0.265818,0.725771,0.590649,0.313560,0.547613,0.946811,0.793753,0.690502,0.276120,0.792995,0.446645}
+
+float y[] = 
{0.389293,10.824917,-0.676577,10.619646,0.283489,11.279525,0.384482,11.586230,0.711259,11.540458,-0.391531,11.281723,0.019900,12.278080,-0.070459,11.104558,0.087938,11.825965,-1.003252,11.698885,0.358887,11.911197,-0.678904,11.933812,0.245140,11.886644}
+
+ TEST COMPLEX SSE3 IMPLEMENTATION: (h_len%4=0) 
+float x[] = 
{0.828957,0.675654,0.904170,0.191112,0.394521,0.706067,0.868924,0.547397,0.738959,0.932485,0.233119,0.926576,0.551443,0.933420,0.494407,0.552568,0.939129,0.799646,0.814139,0.594497,0.657201,0.995300,0.935852,0.324541,0.874309,0.589157,0.637771,0.759324,0.775421,0.794910,0.262785,0.604379,0.470564,0.166955}
+
+float h[] = 
{0.726144,0.746635,0.470674,0.211604,0.963092,0.264553,0.265818,0.725771,0.590649,0.313560,0.547613,0.946811,0.793753,0.690502,0.276120,0.792995,0.446645,0.327805,0.785346,0.676628}
+
+float y[] = 
{-0.641594,12.367426,-0.970113,12.963129,-0.466783,13.747334,0.637486,13.341836,-0.168561,14.091346,0.306652,15.018833,0.233741,14.726789,-0.011241,15.034849,0.000155,13.639509,0.558827,15.495646,-0.406179,14.103148,-0.000244,15.591370,-0.492319,14.785577}
+
+ TEST COMPLEX SSE3 IMPLEMENTATION: (h_len%8=0) 
+float x[] = 
{0.828957,0.675654,0.904170,0.191112,0.394521,0.706067,0.868924,0.547397,0.738959,0.932485,0.233119,0.926576,0.551443,0.933420,0.494407,0.552568,0.939129,0.799646,0.814139,0.594497,0.657201,0.995300,0.935852,0.324541,0.874309,0.589157,0.637771,0.759324,0.775421,0.794910,0.262785,0.604379,0.470564,0.166955}
+
+float h[] = 
{0.726144,0.746635,0.470674,0.211604,0.963092,0.264553,0.265818,0.725771,0.590649,0.313560,0.547613,0.946811,0.793753,0.690502,0.276120,0.792995}
+
+float y[] = 
{-0.278295,10.097409,0.919633,11.502825,0.340383,10.979163,0.891132,11.679869,0.425363,11.186544,1.099703,12.121126,0.188196,11.180099,0.228905,12.436676,0.149904,11.522589,0.543155,11.703615,0.033465,12.425473,0.561782,12.373415,-0.218184,12.154579}
+
+
+
+ TEST REAL BASE IMPLEMENTATION 
+float x[] = 
{0.828957,0.675654,0.904170,0.191112,0.394521,0.706067,0.868924,0.547397,0.738959,0.932485,0.233119,0.926576,0.551443,0.933420,0.494407,0.552568,0.939129,0.799646,0.814139,0.594497,0.657201,0.995300,0.935852,0.324541,0.874309,0.589157,0.637771,0.759324,0.775421,0.794910,0.262785,0.604379,0.470564,0.166955}
+
+float h[] = 
{0.726144,0.746635,0.470674,0.211604,0.963092,0.264553,0.265818,0.725771,0.590649,0.313560,0.547613,0.946811,0.793753,0.690502,0.276120,0.792995,0.446645}
+
+float y[] = 

osmo-bts[master]: osmo-bts-trx: use libosmocoding

2017-05-19 Thread Tom Tsou

Patch Set 3: Code-Review+1

-- 
To view, visit https://gerrit.osmocom.org/2674
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I1b41bb1a8de655639107ec1f3b75afc240fd316f
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Tom Tsou 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


[PATCH] osmo-gsm-tester[master]: ofono_client: Discover modem path from imsi

2017-05-19 Thread Pau Espin Pedrol
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2676

to look at the new patch set (#3).

ofono_client: Discover modem path from imsi

Change-Id: Ib9f4de81abc18e8db0c15df965e4811b6513e1b1
---
M example/resources.conf
M src/osmo_gsm_tester/ofono_client.py
M src/osmo_gsm_tester/resource.py
M src/osmo_gsm_tester/suite.py
4 files changed, 125 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/76/2676/3

diff --git a/example/resources.conf b/example/resources.conf
index cd0216e..b7ac5a3 100644
--- a/example/resources.conf
+++ b/example/resources.conf
@@ -60,21 +60,17 @@
 
 modem:
 - label: sierra_1
-  path: '/sierra_1'
   imsi: '90170009031'
   ki: '80A37E6FDEA931EAC92FFA5F671EFEAD'
 
 - label: sierra_2
-  path: '/sierra_2'
   imsi: '90170009029'
   ki: '00969E283349D354A8239E877F2E0866'
 
 - label: gobi_0
-  path: '/gobi_0'
   imsi: '90170009030'
   ki: 'BB70807226393CDBAC8DD3439FF54252'
 
 - label: gobi_3
-  path: '/gobi_3'
   imsi: '90170009032'
   ki: '2F70DCA43C45ACB97E947FDD0C7CA30A'
diff --git a/src/osmo_gsm_tester/ofono_client.py 
b/src/osmo_gsm_tester/ofono_client.py
index faa9192..12c31e0 100644
--- a/src/osmo_gsm_tester/ofono_client.py
+++ b/src/osmo_gsm_tester/ofono_client.py
@@ -17,7 +17,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see .
 
-from . import log, test, util
+from . import log, test, util, resource
 
 from pydbus import SystemBus, Variant
 import time
@@ -31,6 +31,7 @@
 I_MODEM = 'org.ofono.Modem'
 I_NETREG = 'org.ofono.NetworkRegistration'
 I_SMS = 'org.ofono.MessageManager'
+I_SIM = 'org.ofono.SimManager'
 
 class DeferredHandling:
 defer_queue = []
@@ -57,12 +58,31 @@
 DeferredHandling.defer_queue.'''
 return DeferredHandling(dbus_iface, handler).subscription_id
 
-
 def poll():
 global glib_main_ctx
 while glib_main_ctx.pending():
 glib_main_ctx.iteration()
 DeferredHandling.handle_queue()
+
+def _wait(condition, condition_args, condition_kwargs, timeout, timestep):
+if not timeout or timeout < 0:
+raise RuntimeError('wait() *must* time out at some point. timeout=%r' 
% timeout)
+if timestep < 0.1:
+timestep = 0.1
+
+started = time.time()
+while True:
+poll()
+if condition(*condition_args, **condition_kwargs):
+return True
+waited = time.time() - started
+if waited > timeout:
+return False
+time.sleep(timestep)
+
+def wait(log_obj, condition, *condition_args, timeout=300, timestep=1, 
**condition_kwargs):
+if not _wait(condition, condition_args, condition_kwargs, timeout, 
timestep):
+log_obj.raise_exn('Wait timeout')
 
 def systembus_get(path):
 global bus
@@ -71,6 +91,77 @@
 def list_modems():
 root = systembus_get('/')
 return sorted(root.GetModems())
+
+def modem_is_powered(dbus_obj, val):
+modem_prop = dbus_obj[I_MODEM].GetProperties()
+return modem_prop.get('Powered') == val
+
+def modem_has_val_in_property(dbus_obj, iface, prop_name, val):
+modem_prop = dbus_obj[iface].GetProperties()
+return val in modem_prop.get(prop_name)
+
+def build_imsi_modem_map(log_obj, reserved):
+imsi_modem_map = {}
+poll()
+modems = list_modems()
+for modem_path, prop in modems:
+if modem_path in reserved:
+log_obj.dbg('Modem with path %s is reserved, skipping discovery' % 
modem_path)
+continue
+log_obj.dbg('Discovering imsi for modem %s' % modem_path)
+dbus_obj = systembus_get(modem_path)
+modem_prop = dbus_obj[I_MODEM].GetProperties()
+powered = modem_prop.get('Powered')
+if not powered:
+dbus_obj[I_MODEM].SetProperty('Powered', Variant('b', True))
+wait(log_obj, modem_is_powered, dbus_obj, True)
+
+has_sim_feature = True
+try: # wait for 3 seconds to see if the modem has sim feature
+wait(log_obj, modem_has_val_in_property, dbus_obj, I_MODEM, 
'Features', 'sim', timeout=3)
+except RuntimeError:
+has_sim_feature = False
+log_obj.dbg('modem %s has no sim feature, skipping' % modem_path)
+if has_sim_feature:
+wait(log_obj, modem_has_val_in_property, dbus_obj, I_MODEM, 
'Interfaces', I_SIM)
+sim_prop = dbus_obj[I_SIM].GetProperties()
+imsi = sim_prop.get('SubscriberIdentity')
+if imsi:
+imsi_modem_map[imsi] = modem_path
+
+#Leave in same status as it was:
+if not powered:
+dbus_obj[I_MODEM].SetProperty('Powered', Variant('b', False))
+wait(log_obj, modem_is_powered, dbus_obj, False)
+log_obj.dbg('imsi->modem map:', imsi_modem_map)
+return imsi_modem_map
+
+def reserved_resource_populate_path(log_obj, 

libosmocore[master]: libosmocoding: decode MCS-0 properly

2017-05-19 Thread Vadim Yanitskiy

Patch Set 1: Code-Review+1

-- 
To view, visit https://gerrit.osmocom.org/2675
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I424f7b5494846d2d5cf890f99251dae4ad5bd7d1
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


osmo-gsm-tester[master]: rename resource nitb_iface to eth_iface

2017-05-19 Thread Pau Espin Pedrol

Patch Set 2:

(1 comment)

What about naming it "public_iface" rather than "eth_iface"? Then we have 
public_iface vs lo_iface or private_iface. Instead of "public_iface" at some 
point (msc+bsc split) we may want to have "uplink_iface" and "downlink_iface" 
(which could be set to the same OS iface/ip).

https://gerrit.osmocom.org/#/c/2681/2/src/osmo_gsm_tester/resource.py
File src/osmo_gsm_tester/resource.py:

Line 44: R_NITB_IFACE = 'eth_iface'
missing change here. (NITB). You may want to run grep with CAPS enabled.


-- 
To view, visit https://gerrit.osmocom.org/2681
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I829903d7b2111ab5ee106bce52d6121204a5a401
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: Yes


osmo-bts[master]: osmo-bts-trx: use libosmocoding

2017-05-19 Thread Vadim Yanitskiy

Patch Set 3: Code-Review+1

-- 
To view, visit https://gerrit.osmocom.org/2674
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I1b41bb1a8de655639107ec1f3b75afc240fd316f
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


osmo-gsm-tester[master]: ofono_client: Discover modem path from imsi

2017-05-19 Thread Pau Espin Pedrol

Patch Set 2:

(1 comment)

The main issue is that it's a chicken-egg problem. I cannot properly identify a 
modem until I use it, because we are identifying them using the IMSI and to 
check which is the one I need to potentially power on all of them.

So, I guess to solve that, we would need at startup to dynamically populate the 
shared "resources" config adding the discovered path to each modem resource.

Then, when we want to discover the path from IMSI, we first look there in the 
resources pool. If we cannot get a path from the IMSI, we iterate over ofono 
GetModems() and we only query the ones whose path is not in the "shared 
resource poll".

https://gerrit.osmocom.org/#/c/2676/2/src/osmo_gsm_tester/ofono_client.py
File src/osmo_gsm_tester/ofono_client.py:

Line 70: def _wait(condition, condition_args, condition_kwargs, timeout, 
timestep):
> I'm confused, didn't I write this code? are you moving it around, but I don
I'm duplicating it to avoid the problem to call through test.wait() 
(->suite.wait()). It's not exactly the same because this one calls poll() on 
the same file instead of calling suite.poll() which does more stuff like 
checking for termination of subprocesses. We don't need that here and those 
will nevertherless be checked later on when we provide control to the test at 
some point, and no issue if we don't check that here because we don't interact 
with those processes from this module.


-- 
To view, visit https://gerrit.osmocom.org/2676
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib9f4de81abc18e8db0c15df965e4811b6513e1b1
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: Yes


osmo-gsm-tester[master]: ofono_client: Implement network registration during connect()

2017-05-19 Thread Pau Espin Pedrol

Patch Set 1: Code-Review-1

Not to be merged. I have a newer version but still facing some issues sometimes 
regarding the mt being unregistered.

-- 
To view, visit https://gerrit.osmocom.org/2484
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I3092edc3dd76131da9aeeef6ad5082d1a9009342
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


[ABANDON] osmo-gsm-tester[report]: Handle termination signals to exit gracefully and prevent re...

2017-05-19 Thread Pau Espin Pedrol
Pau Espin Pedrol has abandoned this change.

Change subject: Handle termination signals to exit gracefully and prevent 
resource leak
..


Abandoned

-- 
To view, visit https://gerrit.osmocom.org/2670
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: abandon
Gerrit-Change-Id: I039e4d1908a04bf606b101ddc6a186ba67e6178e
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: report
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 


[PATCH] osmo-gsm-tester[master]: Handle termination signals to exit gracefully and prevent re...

2017-05-19 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/2684

Handle termination signals to exit gracefully and prevent resource leak

Make sure we free the reserved resources and kill launched subprocesses
before stopping. Before this patch it was not the case for instance if we
received a SIGTREM signal from kill.

Change-Id: I039e4d1908a04bf606b101ddc6a186ba67e6178e
---
M src/osmo-gsm-tester.py
M src/osmo_gsm_tester/suite.py
2 files changed, 34 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/84/2684/1

diff --git a/src/osmo-gsm-tester.py b/src/osmo-gsm-tester.py
index 504c6a9..766f356 100755
--- a/src/osmo-gsm-tester.py
+++ b/src/osmo-gsm-tester.py
@@ -68,10 +68,22 @@
 
 import sys
 import argparse
+from signal import *
 from osmo_gsm_tester import __version__
 from osmo_gsm_tester import trial, suite, log, config
 
+def sig_handler_cleanup(signum, frame):
+print("killed by signal %d" % signum)
+# This sys.exit() will raise a SystemExit base exception at the current
+# point of execution. Code must be prepared to clean system-wide resources
+# by using the "finally" section. This allows at the end 'atexit' hooks to
+# be called before exiting.
+sys.exit(1)
+
 def main():
+
+for sig in (SIGINT, SIGTERM, SIGQUIT, SIGPIPE, SIGHUP):
+signal(sig, sig_handler_cleanup)
 
 parser = argparse.ArgumentParser(epilog=__doc__, 
formatter_class=argparse.RawTextHelpFormatter)
 # Note: since we're using RawTextHelpFormatter to keep nicely separate
@@ -184,7 +196,8 @@
 if status == trial.Trial.FAIL:
 any_failed = True
 trials_run.append(current_trial)
-except:
+except Exception:
+# Do not catch here subclasses of BaseException such as 
SystemExit, let them finish the program
 current_trial.log_exn()
 
 sys.stderr.flush()
diff --git a/src/osmo_gsm_tester/suite.py b/src/osmo_gsm_tester/suite.py
index e05f0d7..64de2db 100644
--- a/src/osmo_gsm_tester/suite.py
+++ b/src/osmo_gsm_tester/suite.py
@@ -223,21 +223,26 @@
 
 def run_tests(self, names=None):
 self.log('Suite run start')
-self.mark_start()
-if not self.reserved_resources:
-self.reserve_resources()
-for test in self.definition.tests:
-if names and not test.name() in names:
-test.set_skip()
-self.test_skipped_ctr += 1
-self.tests.append(test)
-continue
-with self:
-st = test.run(self)
-if st == Test.FAIL:
-self.test_failed_ctr += 1
-self.tests.append(test)
-self.stop_processes()
+try:
+self.mark_start()
+if not self.reserved_resources:
+self.reserve_resources()
+for test in self.definition.tests:
+if names and not test.name() in names:
+test.set_skip()
+self.test_skipped_ctr += 1
+self.tests.append(test)
+continue
+with self:
+st = test.run(self)
+if st == Test.FAIL:
+self.test_failed_ctr += 1
+self.tests.append(test)
+finally:
+# if sys.exit() called from signal handler (e.g. SIGINT), 
SystemExit
+# base exception is raised. Make sure to stop processes in this
+# finally section. Resources are automatically freed with 'atexit'.
+self.stop_processes()
 self.duration = time.time() - self.start_timestamp
 if self.test_failed_ctr:
 self.status = SuiteRun.FAIL

-- 
To view, visit https://gerrit.osmocom.org/2684
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I039e4d1908a04bf606b101ddc6a186ba67e6178e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 


[MERGED] openbsc[master]: fix '/include/openbsc ' to have no trailing space

2017-05-19 Thread Neels Hofmeyr
Neels Hofmeyr has submitted this change and it was merged.

Change subject: fix '/include/openbsc ' to have no trailing space
..


fix '/include/openbsc ' to have no trailing space

The newline and $NULL manage to append a trailing space to the 'openbsc' dir.

This was broken in commit 7b6673fa06dada3ec4586b1c0d735e9df4177a48
"Consistenly format variables in */Makefile.am files"
by Change-Id Ifa21513c007072314097b7bec188579972dc1694

Add a comment to prevent this in the future.

Reported-by: Andreas Mueller 
Change-Id: I218027459e3b2aaa817d91eb3f69d9c0b10dcd4e
---
M openbsc/include/openbsc/Makefile.am
1 file changed, 3 insertions(+), 3 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/openbsc/include/openbsc/Makefile.am 
b/openbsc/include/openbsc/Makefile.am
index 7ddf323..eb09e18 100644
--- a/openbsc/include/openbsc/Makefile.am
+++ b/openbsc/include/openbsc/Makefile.am
@@ -93,6 +93,6 @@
meas_rep.h \
$(NULL)
 
-openbscdir = \
-   $(includedir)/openbsc \
-   $(NULL)
+# DO NOT add a newline and '$(NULL)' to this line. That would add a trailing
+# space to the directory installed: $prefix/include/'openbsc '
+openbscdir = $(includedir)/openbsc

-- 
To view, visit https://gerrit.osmocom.org/2649
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I218027459e3b2aaa817d91eb3f69d9c0b10dcd4e
Gerrit-PatchSet: 2
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


[ABANDON] osmo-gsm-tester[master]: sysmo: use abspath of run dir, to fix scp of cfg to sysmobts

2017-05-19 Thread Neels Hofmeyr
Neels Hofmeyr has abandoned this change.

Change subject: sysmo: use abspath of run dir, to fix scp of cfg to sysmobts
..


Abandoned

problem fixed by another abspath patch

-- 
To view, visit https://gerrit.osmocom.org/2606
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: abandon
Gerrit-Change-Id: Ib430657fd0d83a1a59b4b4b0ad6186c95347cb7b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


[MERGED] osmo-gsm-tester[master]: Add JUnit XML reports; refactor test reporting

2017-05-19 Thread Pau Espin Pedrol
Pau Espin Pedrol has submitted this change and it was merged.

Change subject: Add JUnit XML reports; refactor test reporting
..


Add JUnit XML reports; refactor test reporting

* Add Junit output file support
* Differentiate between an expected failure test and an error in the
test, as described in JUnit.
* In case of an error/exception during test, record and attach it to the
Test object and continue running the tests, and show it at the end
during the trial report.

Change-Id: Iedf6d912b3ccea187a4ac6d5c6b70fe9d5c5
---
M .gitignore
M selftest/suite_test.ok
M selftest/suite_test.py
A selftest/suite_test/test_suite/test_fail.py
A selftest/suite_test/test_suite/test_fail_raise.py
M selftest/trial_test.ok
M src/osmo-gsm-tester.py
A src/osmo_gsm_tester/report.py
M src/osmo_gsm_tester/suite.py
M src/osmo_gsm_tester/test.py
M src/osmo_gsm_tester/trial.py
A suites/debug/error.py
M suites/debug/fail.py
A suites/debug/fail_raise.py
A suites/debug/pass.py
15 files changed, 290 insertions(+), 91 deletions(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/.gitignore b/.gitignore
index 4119e7f..1ab84d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@
 test_work
 state
 *.pyc
+selftest/trial_test/
diff --git a/selftest/suite_test.ok b/selftest/suite_test.ok
index fda77dc..30c6915 100644
--- a/selftest/suite_test.ok
+++ b/selftest/suite_test.ok
@@ -59,15 +59,30 @@
 tst hello_world.py:[LINENR]: two  [test_suite↪hello_world.py:[LINENR]]
 tst hello_world.py:[LINENR]: three  [test_suite↪hello_world.py:[LINENR]]
 tst hello_world.py:[LINENR] PASS  [test_suite↪hello_world.py]
-pass: all 1 tests passed.
+tst test_suite: PASS
+pass: all 6 tests passed (5 skipped).
 
 - a test with an error
 tst test_suite: Suite run start  [suite.py:[LINENR]]
 tst test_error.py:[LINENR] START  [test_suite↪test_error.py]  
[suite.py:[LINENR]]
 tst test_error.py:[LINENR]: I am 'test_suite' / 'test_error.py:[LINENR]'  
[test_suite↪test_error.py:[LINENR]]  [test_error.py:[LINENR]]
-tst test_error.py:[LINENR]: FAIL  [test_suite↪test_error.py:[LINENR]]  
[suite.py:[LINENR]]
-tst test_error.py:[LINENR]: ERR: AssertionError:   
[test_suite↪test_error.py:[LINENR]]  [test_error.py:[LINENR]: assert False]
-FAIL: 1 of 1 tests failed:
-  test_error.py
+tst test_error.py:[LINENR]: ERR: AssertionError:   [test_error.py:[LINENR]: 
assert False]
+tst test_error.py:[LINENR] FAIL (AssertionError)  [test_suite↪test_error.py]  
[suite.py:[LINENR]]
+tst test_suite: FAIL  [suite.py:[LINENR]]
+
+- a test with a failure
+tst test_suite: Suite run start  [suite.py:[LINENR]]
+tst test_fail.py:[LINENR] START  [test_suite↪test_fail.py]  [suite.py:[LINENR]]
+tst test_fail.py:[LINENR]: I am 'test_suite' / 'test_fail.py:[LINENR]'  
[test_suite↪test_fail.py:[LINENR]]  [test_fail.py:[LINENR]]
+tst test_fail.py:[LINENR] FAIL (EpicFail)  [test_suite↪test_fail.py]  
[suite.py:[LINENR]]
+tst test_suite: FAIL  [suite.py:[LINENR]]
+
+- a test with a raised failure
+tst test_suite: Suite run start  [suite.py:[LINENR]]
+tst test_fail_raise.py:[LINENR] START  [test_suite↪test_fail_raise.py]  
[suite.py:[LINENR]]
+tst test_fail_raise.py:[LINENR]: I am 'test_suite' / 
'test_fail_raise.py:[LINENR]'  [test_suite↪test_fail_raise.py:[LINENR]]  
[test_fail_raise.py:[LINENR]]
+tst test_fail_raise.py:[LINENR]: ERR: Failure: ('EpicFail', 'This failure is 
expected')  [test_fail_raise.py:[LINENR]: raise Failure('EpicFail', 'This 
failure is expected')]
+tst test_fail_raise.py:[LINENR] FAIL (EpicFail)  
[test_suite↪test_fail_raise.py]  [suite.py:[LINENR]]
+tst test_suite: FAIL  [suite.py:[LINENR]]
 
 - graceful exit.
diff --git a/selftest/suite_test.py b/selftest/suite_test.py
index 315c683..16342c5 100755
--- a/selftest/suite_test.py
+++ b/selftest/suite_test.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 import os
 import _prep
-from osmo_gsm_tester import log, suite, config
+from osmo_gsm_tester import log, suite, config, report
 
 config.ENV_CONF = './suite_test'
 
@@ -22,13 +22,33 @@
 print('- run hello world test')
 s = suite.SuiteRun(None, 'test_suite', s_def)
 results = s.run_tests('hello_world.py')
-print(str(results))
+print(report.suite_to_text(s))
 
 log.style_change(src=True)
 #log.style_change(trace=True)
 print('\n- a test with an error')
 results = s.run_tests('test_error.py')
-print(str(results))
+output = report.suite_to_text(s)
+assert 'FAIL: [test_suite] 1 failed ' in output
+assert 'FAIL: [test_error.py]' in output
+assert "type:'AssertionError' message: AssertionError()" in output
+assert 'assert False' in output
+
+print('\n- a test with a failure')
+results = s.run_tests('test_fail.py')
+output = report.suite_to_text(s)
+assert 'FAIL: [test_suite] 1 failed ' in output
+assert 'FAIL: [test_fail.py]' in output
+assert "type:'EpicFail' message: This failure is expected" in output
+assert "test.set_fail('EpicFail', 'This failure is expected')" in 

osmo-gsm-tester[master]: Add JUnit XML reports; refactor test reporting

2017-05-19 Thread Neels Hofmeyr

Patch Set 9: Code-Review+2

yay!

-- 
To view, visit https://gerrit.osmocom.org/2669
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Iedf6d912b3ccea187a4ac6d5c6b70fe9d5c5
Gerrit-PatchSet: 9
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 
Gerrit-HasComments: No


[PATCH] osmo-bts[master]: Remove redundant test

2017-05-19 Thread Max

Review at  https://gerrit.osmocom.org/2683

Remove redundant test

After switching to libosmocoding there's no need in low-level bursts
test which is part of libosmocoding anyway.

Change-Id: Icb8caf62ac653a39a7a82f2225e8edeab7f5afb5
---
M .gitignore
M configure.ac
M tests/Makefile.am
D tests/bursts/Makefile.am
D tests/bursts/bursts_test.c
D tests/bursts/bursts_test.ok
M tests/testsuite.at
7 files changed, 1 insertion(+), 535 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/83/2683/1

diff --git a/.gitignore b/.gitignore
index b449f92..19ca274 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,7 +46,6 @@
 tests/cipher/cipher_test
 tests/sysmobts/sysmobts_test
 tests/misc/misc_test
-tests/bursts/bursts_test
 tests/handover/handover_test
 tests/tx_power/tx_power_test
 tests/testsuite
diff --git a/configure.ac b/configure.ac
index 72dd600..b848605 100644
--- a/configure.ac
+++ b/configure.ac
@@ -186,7 +186,6 @@
 tests/cipher/Makefile
 tests/sysmobts/Makefile
 tests/misc/Makefile
-tests/bursts/Makefile
 tests/handover/Makefile
 tests/tx_power/Makefile
 Makefile)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6635ae7..5b6f65e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = paging cipher agch misc bursts handover tx_power
+SUBDIRS = paging cipher agch misc handover tx_power
 
 if ENABLE_SYSMOBTS
 SUBDIRS += sysmobts
diff --git a/tests/bursts/Makefile.am b/tests/bursts/Makefile.am
deleted file mode 100644
index 380b4b8..000
--- a/tests/bursts/Makefile.am
+++ /dev/null
@@ -1,8 +0,0 @@
-AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR)
-AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) 
$(LIBOSMOCODEC_CFLAGS) $(LIBOSMOCODING_CFLAGS)
-LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS) 
$(LIBOSMOCODING_LIBS)
-noinst_PROGRAMS = bursts_test
-EXTRA_DIST = bursts_test.ok
-
-bursts_test_SOURCES = bursts_test.c
-bursts_test_LDADD = $(top_builddir)/src/common/libbts.a $(LDADD)
diff --git a/tests/bursts/bursts_test.c b/tests/bursts/bursts_test.c
deleted file mode 100644
index 9c2efdf..000
--- a/tests/bursts/bursts_test.c
+++ /dev/null
@@ -1,497 +0,0 @@
-/* (C) 2013 by Andreas Eversberg 
- * (C) 2015 by Alexander Chemeris 
- *
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see .
- *
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-
-#include 
-#include 
-
-#define ASSERT_TRUE(rc) \
-   if (!(rc)) { \
-   printf("Assert failed in %s:%d.\n",  \
-  __FILE__, __LINE__);  \
-   abort(); \
-   }
-
-/* set condition to 1, to show debugging */
-#define printd if (0) printf
-
-static int ubits2sbits(ubit_t *ubits, sbit_t *sbits, int count)
-{
-   int i;
-
-   for (i = 0; i < count; i++) {
-   if (*ubits == 0x23) {
-   ubits++;
-   sbits++;
-   continue;
-   }
-   if ((*ubits++) & 1)
-   *sbits++ = -127;
-   else
-   *sbits++ = 127;
-   }
-
-   return count;
-}
-
-static void test_xcch(uint8_t *l2)
-{
-   uint8_t result[23];
-   ubit_t bursts_u[116 * 4];
-   sbit_t bursts_s[116 * 4];
-   int n_errors, n_bits_total;
-
-   printd("Encoding: %s\n", osmo_hexdump(l2, 23));
-
-   /* encode */
-   gsm0503_xcch_encode(bursts_u, l2);
-
-   printd("U-Bits:\n");
-   printd("%s %02x  %02x  ", osmo_hexdump(bursts_u, 57),
-   bursts_u[57], bursts_u[58]);
-   printd("%s\n", osmo_hexdump(bursts_u + 59, 57));
-   printd("%s %02x  %02x  ", osmo_hexdump(bursts_u + 116, 57),
-   bursts_u[57 + 116], bursts_u[58 + 116]);
-   printd("%s\n", osmo_hexdump(bursts_u + 59 + 116, 57));
-   printd("%s %02x  %02x  ", osmo_hexdump(bursts_u + 232, 57),
-   bursts_u[57 + 232], bursts_u[58 + 232]);
-   printd("%s\n", osmo_hexdump(bursts_u + 59 + 232, 57));
-   printd("%s %02x  %02x  ", osmo_hexdump(bursts_u + 348, 57),
-   bursts_u[57 + 348], bursts_u[58 + 348]);
-   printd("%s\n", osmo_hexdump(bursts_u + 59 + 348, 57));

osmo-gsm-tester[master]: Add JUnit XML reports; refactor test reporting

2017-05-19 Thread Neels Hofmeyr

Patch Set 8: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/2669
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Iedf6d912b3ccea187a4ac6d5c6b70fe9d5c5
Gerrit-PatchSet: 8
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 
Gerrit-HasComments: No


osmo-gsm-tester[report]: Handle termination signals to exit gracefully and prevent re...

2017-05-19 Thread Pau Espin Pedrol

Patch Set 2:

(2 comments)

https://gerrit.osmocom.org/#/c/2670/2/src/osmo-gsm-tester.py
File src/osmo-gsm-tester.py:

Line 200: except Exception:
> this is made stricter to not catch SystemExit? because we don't want to del
Indeed, otherwise SystemExit is dropped here (there's no raise, and it's better 
without it as there's another except in __main__ already to catch those.


https://gerrit.osmocom.org/#/c/2670/2/src/osmo_gsm_tester/suite.py
File src/osmo_gsm_tester/suite.py:

Line 269: self.stop_processes()
> this stops child processes, but how is the resource cleaning ensured? via a
Yes it is. I will add it to the comment.


-- 
To view, visit https://gerrit.osmocom.org/2670
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I039e4d1908a04bf606b101ddc6a186ba67e6178e
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: report
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 
Gerrit-HasComments: Yes


[PATCH] osmo-gsm-tester[master]: Add JUnit XML reports; refactor test reporting

2017-05-19 Thread Pau Espin Pedrol
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2669

to look at the new patch set (#8).

Add JUnit XML reports; refactor test reporting

* Add Junit output file support
* Differentiate between an expected failure test and an error in the
test, as described in JUnit.
* In case of an error/exception during test, record and attach it to the
Test object and continue running the tests, and show it at the end
during the trial report.

Change-Id: Iedf6d912b3ccea187a4ac6d5c6b70fe9d5c5
---
M .gitignore
M selftest/suite_test.ok
M selftest/suite_test.py
A selftest/suite_test/test_suite/test_fail.py
A selftest/suite_test/test_suite/test_fail_raise.py
M selftest/trial_test.ok
M src/osmo-gsm-tester.py
A src/osmo_gsm_tester/report.py
M src/osmo_gsm_tester/suite.py
M src/osmo_gsm_tester/test.py
M src/osmo_gsm_tester/trial.py
A suites/debug/error.py
M suites/debug/fail.py
A suites/debug/fail_raise.py
A suites/debug/pass.py
15 files changed, 290 insertions(+), 91 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/69/2669/8

diff --git a/.gitignore b/.gitignore
index 4119e7f..1ab84d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@
 test_work
 state
 *.pyc
+selftest/trial_test/
diff --git a/selftest/suite_test.ok b/selftest/suite_test.ok
index fda77dc..30c6915 100644
--- a/selftest/suite_test.ok
+++ b/selftest/suite_test.ok
@@ -59,15 +59,30 @@
 tst hello_world.py:[LINENR]: two  [test_suite↪hello_world.py:[LINENR]]
 tst hello_world.py:[LINENR]: three  [test_suite↪hello_world.py:[LINENR]]
 tst hello_world.py:[LINENR] PASS  [test_suite↪hello_world.py]
-pass: all 1 tests passed.
+tst test_suite: PASS
+pass: all 6 tests passed (5 skipped).
 
 - a test with an error
 tst test_suite: Suite run start  [suite.py:[LINENR]]
 tst test_error.py:[LINENR] START  [test_suite↪test_error.py]  
[suite.py:[LINENR]]
 tst test_error.py:[LINENR]: I am 'test_suite' / 'test_error.py:[LINENR]'  
[test_suite↪test_error.py:[LINENR]]  [test_error.py:[LINENR]]
-tst test_error.py:[LINENR]: FAIL  [test_suite↪test_error.py:[LINENR]]  
[suite.py:[LINENR]]
-tst test_error.py:[LINENR]: ERR: AssertionError:   
[test_suite↪test_error.py:[LINENR]]  [test_error.py:[LINENR]: assert False]
-FAIL: 1 of 1 tests failed:
-  test_error.py
+tst test_error.py:[LINENR]: ERR: AssertionError:   [test_error.py:[LINENR]: 
assert False]
+tst test_error.py:[LINENR] FAIL (AssertionError)  [test_suite↪test_error.py]  
[suite.py:[LINENR]]
+tst test_suite: FAIL  [suite.py:[LINENR]]
+
+- a test with a failure
+tst test_suite: Suite run start  [suite.py:[LINENR]]
+tst test_fail.py:[LINENR] START  [test_suite↪test_fail.py]  [suite.py:[LINENR]]
+tst test_fail.py:[LINENR]: I am 'test_suite' / 'test_fail.py:[LINENR]'  
[test_suite↪test_fail.py:[LINENR]]  [test_fail.py:[LINENR]]
+tst test_fail.py:[LINENR] FAIL (EpicFail)  [test_suite↪test_fail.py]  
[suite.py:[LINENR]]
+tst test_suite: FAIL  [suite.py:[LINENR]]
+
+- a test with a raised failure
+tst test_suite: Suite run start  [suite.py:[LINENR]]
+tst test_fail_raise.py:[LINENR] START  [test_suite↪test_fail_raise.py]  
[suite.py:[LINENR]]
+tst test_fail_raise.py:[LINENR]: I am 'test_suite' / 
'test_fail_raise.py:[LINENR]'  [test_suite↪test_fail_raise.py:[LINENR]]  
[test_fail_raise.py:[LINENR]]
+tst test_fail_raise.py:[LINENR]: ERR: Failure: ('EpicFail', 'This failure is 
expected')  [test_fail_raise.py:[LINENR]: raise Failure('EpicFail', 'This 
failure is expected')]
+tst test_fail_raise.py:[LINENR] FAIL (EpicFail)  
[test_suite↪test_fail_raise.py]  [suite.py:[LINENR]]
+tst test_suite: FAIL  [suite.py:[LINENR]]
 
 - graceful exit.
diff --git a/selftest/suite_test.py b/selftest/suite_test.py
index 315c683..16342c5 100755
--- a/selftest/suite_test.py
+++ b/selftest/suite_test.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 import os
 import _prep
-from osmo_gsm_tester import log, suite, config
+from osmo_gsm_tester import log, suite, config, report
 
 config.ENV_CONF = './suite_test'
 
@@ -22,13 +22,33 @@
 print('- run hello world test')
 s = suite.SuiteRun(None, 'test_suite', s_def)
 results = s.run_tests('hello_world.py')
-print(str(results))
+print(report.suite_to_text(s))
 
 log.style_change(src=True)
 #log.style_change(trace=True)
 print('\n- a test with an error')
 results = s.run_tests('test_error.py')
-print(str(results))
+output = report.suite_to_text(s)
+assert 'FAIL: [test_suite] 1 failed ' in output
+assert 'FAIL: [test_error.py]' in output
+assert "type:'AssertionError' message: AssertionError()" in output
+assert 'assert False' in output
+
+print('\n- a test with a failure')
+results = s.run_tests('test_fail.py')
+output = report.suite_to_text(s)
+assert 'FAIL: [test_suite] 1 failed ' in output
+assert 'FAIL: [test_fail.py]' in output
+assert "type:'EpicFail' message: This failure is expected" in output
+assert "test.set_fail('EpicFail', 'This failure is expected')" in output
+
+print('\n- a test with a raised 

osmo-gsm-tester[master]: Add JUnit XML reports; refactor test reporting

2017-05-19 Thread Pau Espin Pedrol

Patch Set 7:

(3 comments)

https://gerrit.osmocom.org/#/c/2669/7/src/osmo_gsm_tester/suite.py
File src/osmo_gsm_tester/suite.py:

Line 109: self.fail_message = ''
> set these to None instead?
Done


Line 151: self.duration = round(time.time() - self.start_timestamp)
> you are rounding because...? for cosmetic reasons? Rather ceil() so we don'
JUNit supports only an integer value for this. I'll keep the float here and do 
the int conversion in the JUNit specific code.


Line 186: def clear_test_vars(self):
> still '_test_vars' sounds like it is related to the environment for a test 
- About naming: as I already said, I like the current or the previous name, but 
I'll again change it if you like it more as 'mark_start()'.
- Better not move into __init__ because we still want to return the status code.
- I call this function during __init__ to just in case at some point someone 
decides to print the SuiteRun (or write a report) or get status or whatever 
before running the test. Anyway, I will remove it.


-- 
To view, visit https://gerrit.osmocom.org/2669
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Iedf6d912b3ccea187a4ac6d5c6b70fe9d5c5
Gerrit-PatchSet: 7
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 
Gerrit-HasComments: Yes


osmo-gsm-tester[master]: ofono_client: Discover modem path from imsi

2017-05-19 Thread Neels Hofmeyr

Patch Set 2: Code-Review-1

(2 comments)

https://gerrit.osmocom.org/#/c/2676/2/src/osmo_gsm_tester/ofono_client.py
File src/osmo_gsm_tester/ofono_client.py:

Line 70: def _wait(condition, condition_args, condition_kwargs, timeout, 
timestep):
I'm confused, didn't I write this code? are you moving it around, but I don't 
see it being removed elsewhere? duplicating it?


Line 123: wait(log_obj, modem_is_powered, dbus_obj, True)
hmm I see a problem here that I didn't think of before. If another run is using 
a modem, we must not interfere. Even if we see it is not powered, then do our 
thing, the other run in the meantime may have decided to power it, and we must 
not power it off again even though that was the state when we started.

So what we need to do:

Get the state of currently reserved modems, and

a) do not touch those that are currently reserved.

b) reserve modems, then fetch the IMSI, then free the reservation.

c) from a., the list will omit modems that are currently reserved. So we may 
need to re-run the IMSI discovery for every suite run. Alternatively we could 
keep the discovered IMSIs in the state file -- but if modems change due to 
$foo, we still need to re-run.

Let me know if you need help with the code to reserve resources...


-- 
To view, visit https://gerrit.osmocom.org/2676
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib9f4de81abc18e8db0c15df965e4811b6513e1b1
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: Yes


libosmocore[master]: libosmocoding: decode MCS-0 properly

2017-05-19 Thread Max

Patch Set 1: -Code-Review

Ok, turned out to be local configuration issue. It doesn't fix the issue I've 
aimed for but I still think it's a nice addition overall.

-- 
To view, visit https://gerrit.osmocom.org/2675
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I424f7b5494846d2d5cf890f99251dae4ad5bd7d1
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-HasComments: No


osmo-gsm-tester[report]: Handle termination signals to exit gracefully and prevent re...

2017-05-19 Thread Neels Hofmeyr

Patch Set 2: Code-Review+1

(2 comments)

https://gerrit.osmocom.org/#/c/2670/2/src/osmo-gsm-tester.py
File src/osmo-gsm-tester.py:

Line 200: except Exception:
this is made stricter to not catch SystemExit? because we don't want to delay 
by writing to a log file? (maybe place a comment)


https://gerrit.osmocom.org/#/c/2670/2/src/osmo_gsm_tester/suite.py
File src/osmo_gsm_tester/suite.py:

Line 269: self.stop_processes()
this stops child processes, but how is the resource cleaning ensured? via 
atexit, right? (could be mentioned in the comment)


-- 
To view, visit https://gerrit.osmocom.org/2670
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I039e4d1908a04bf606b101ddc6a186ba67e6178e
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: report
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 
Gerrit-HasComments: Yes


osmo-gsm-tester[master]: Add JUnit XML reports; refactor test reporting

2017-05-19 Thread Neels Hofmeyr

Patch Set 7: Code-Review+1

(4 comments)

I like this now. Minor comments...

https://gerrit.osmocom.org/#/c/2669/7/src/osmo_gsm_tester/suite.py
File src/osmo_gsm_tester/suite.py:

Line 109: self.fail_message = ''
set these to None instead?


Line 151: self.duration = round(time.time() - self.start_timestamp)
you are rounding because...? for cosmetic reasons? Rather ceil() so we don't 
make it shorter than it was ... or just keep the entire float value?


Line 186: def clear_test_vars(self):
still '_test_vars' sounds like it is related to the environment for a test 
script (like test.py:setup()). My favorites now are 'start()' or 
'mark_start()'. Not blocking because of this.

Still the argument remains that SuiteRun is intended to be run only once. We 
instantiate the class right when we start the suite run, so this should 
actually move into __init__? If it's cubersome to adjust the regression tests 
to this, though, I agree to keep this separate.


Line 227: self.clear_test_vars()
why call in the constructor *and* here?


-- 
To view, visit https://gerrit.osmocom.org/2669
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Iedf6d912b3ccea187a4ac6d5c6b70fe9d5c5
Gerrit-PatchSet: 7
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 
Gerrit-HasComments: Yes


osmo-ci[master]: Introduce artifacts holding dependencies to speed up builds.

2017-05-19 Thread Neels Hofmeyr

Patch Set 7: Code-Review-1

(12 comments)

thanks for working on this! Here is some more review...

https://gerrit.osmocom.org/#/c/2465/7/scripts/osmo-build.sh
File scripts/osmo-build.sh:

Line 23: # More information about those function are given in the following 
template:
This is an example for building  which depends on , 
, 


Line 28: #  # Specify dependencies in the following way:
More and better docs. It is absolutely crucial that anyone who may take over 
jenkins maintenance can easily understand this. e.g.

  Pass all required dependencies to a command given in $1.
  Collect the output of these calls and concatenate, separated with underscores.
  The result is an artifact file name used to store in/retrieve from the 
artifact store.

  $1 may be one of these commands:

  - osmo-build-dep.sh: build a source tree
  - getFoo: frobnicate zagnomodes
  - getMoo: instacube labnitudes

  The arguments passed to these are:
  
  - PARALLEL_MAKE as environment variable, passed to 'make'
  - arg 1: the git repository name, gets places in a git.osmocom.org URL.
  - arg 2: optional: ...
  - arg 3: optional: ...


Line 43: #  #   - getArtifactNameRemotely()  (osmo-build.sh)
(rather put this on top like above)


Line 49: #  # in jenkins' $WORKSPACE per default.
like what. cd foo? ./configure && make install?


Line 55: # The JOB_NAME variables will be injected to each jenkins' job by 
jenkins itself.
let's have what this script needs right at the top


Line 82: 
comment: "jenkins should check out the git tree of the project to be built in 
the workspace root." (this probably near the top of this file) and here "obtain 
the project name from the git clone found in the workspace root"


Line 86:job_name="${JOB_NAME//\//#}"
what does this do?


Line 130: 
locally? remotely?


Line 163:   # be on a different partition or build runs in docker.
you're lacking the root reason: we want to atomically move an artifact into 
place avoiding half-written files.


Line 171:   rm -f "$job_store/*"
hmm, we might still have a GC problem here. If another job tries to use this 
artifact and this job is removing it? -- that depends on whether we retrieve 
the artifact "atomically"...


Line 187:   generateArtifactHashes "$1"
add comment:

  # extract the artifact directly from the artifact store.
  # If another job run were to remove the artifact while we're doing this,
  # we trust that 'tar' will keep the file open and thus we are allowed 
  # to read to the end before the file is discarded by the OS.

And about the GC problem above: the most waterproof way of avoiding is to probe 
whether the artifact exists *by* doing a copy/untar. If it succeeds, we have 
it. If not, rebuild. In case we first query and decide, then copy, some other 
job run may have removed in the meantime?

How likely is this to happen? What would it take? concurrent jenkins job builds 
of different versions of the same repos? (so far we have concurrent builds 
disabled mostly for cosmetic reasons)


Line 193: generateArtifactHashes() {
rename to 'logArtifactHashes'


-- 
To view, visit https://gerrit.osmocom.org/2465
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ifee0a2f837d23b19aa5326f810234d5452e47484
Gerrit-PatchSet: 7
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Owner: blobb 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: blobb 
Gerrit-Reviewer: neels 
Gerrit-HasComments: Yes


[PATCH] openbsc[master]: Add missing _CFLAGS and _LIBS

2017-05-19 Thread Alexander Huemer
Hello Max, Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2652

to look at the new patch set (#2).

Add missing _CFLAGS and _LIBS

These missing pieces go unnoticed if dependencies are not installed in
distinct directories.

Change-Id: If8d57b72f63d79cc0d8efba7466c6ec177207cbb
---
M openbsc/src/gprs/Makefile.am
M openbsc/src/utils/Makefile.am
M openbsc/tests/sndcp_xid/Makefile.am
3 files changed, 6 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/52/2652/2

diff --git a/openbsc/src/gprs/Makefile.am b/openbsc/src/gprs/Makefile.am
index cff17dd..cb09979 100644
--- a/openbsc/src/gprs/Makefile.am
+++ b/openbsc/src/gprs/Makefile.am
@@ -99,8 +99,8 @@
$(LIBOSMOABIS_LIBS) \
$(LIBCARES_LIBS) \
$(LIBCRYPTO_LIBS) \
+   $(LIBGTP_LIBS) \
-lrt \
-   -lgtp \
-lm \
$(NULL)
 if BUILD_IU
diff --git a/openbsc/src/utils/Makefile.am b/openbsc/src/utils/Makefile.am
index 9c3837a..26494e1 100644
--- a/openbsc/src/utils/Makefile.am
+++ b/openbsc/src/utils/Makefile.am
@@ -109,6 +109,7 @@
 osmo_meas_pcap2db_CFLAGS = \
$(LIBOSMOCORE_CFLAGS) \
$(LIBOSMOGSM_CFLAGS) \
+   $(LIBOSMOABIS_CFLAGS) \
$(NULL)
 
 osmo_meas_udp2db_SOURCES = \
@@ -125,6 +126,7 @@
 osmo_meas_udp2db_CFLAGS = \
$(LIBOSMOCORE_CFLAGS) \
$(LIBOSMOGSM_CFLAGS) \
+   $(LIBOSMOABIS_CFLAGS) \
$(NULL)
 
 meas_json_SOURCES = \
@@ -140,5 +142,6 @@
 meas_json_CFLAGS = \
$(LIBOSMOCORE_CFLAGS) \
$(LIBOSMOGSM_CFLAGS) \
+   $(LIBOSMOABIS_CFLAGS) \
$(NULL)
 
diff --git a/openbsc/tests/sndcp_xid/Makefile.am 
b/openbsc/tests/sndcp_xid/Makefile.am
index 99b9d1a..d09c41b 100644
--- a/openbsc/tests/sndcp_xid/Makefile.am
+++ b/openbsc/tests/sndcp_xid/Makefile.am
@@ -15,6 +15,7 @@
$(LIBOSMOGB_LIBS) \
$(LIBCARES_LIBS) \
$(LIBCRYPTO_LIBS) \
-   -lgtp -lrt -lm
+   $(LIBGTP_LIBS) \
+   -lrt -lm
 
 

-- 
To view, visit https://gerrit.osmocom.org/2652
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If8d57b72f63d79cc0d8efba7466c6ec177207cbb
Gerrit-PatchSet: 2
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Alexander Huemer 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 


[PATCH] osmo-gsm-tester[master]: Add JUnit XML reports; refactor test reporting

2017-05-19 Thread Pau Espin Pedrol
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2669

to look at the new patch set (#7).

Add JUnit XML reports; refactor test reporting

* Add Junit output file support
* Differentiate between an expected failure test and an error in the
test, as described in JUnit.
* In case of an error/exception during test, record and attach it to the
Test object and continue running the tests, and show it at the end
during the trial report.

Change-Id: Iedf6d912b3ccea187a4ac6d5c6b70fe9d5c5
---
M .gitignore
M selftest/suite_test.ok
M selftest/suite_test.py
A selftest/suite_test/test_suite/test_fail.py
A selftest/suite_test/test_suite/test_fail_raise.py
M selftest/trial_test.ok
M src/osmo-gsm-tester.py
A src/osmo_gsm_tester/report.py
M src/osmo_gsm_tester/suite.py
M src/osmo_gsm_tester/test.py
M src/osmo_gsm_tester/trial.py
A suites/debug/error.py
M suites/debug/fail.py
A suites/debug/fail_raise.py
A suites/debug/pass.py
15 files changed, 291 insertions(+), 91 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/69/2669/7

diff --git a/.gitignore b/.gitignore
index 4119e7f..1ab84d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@
 test_work
 state
 *.pyc
+selftest/trial_test/
diff --git a/selftest/suite_test.ok b/selftest/suite_test.ok
index fda77dc..30c6915 100644
--- a/selftest/suite_test.ok
+++ b/selftest/suite_test.ok
@@ -59,15 +59,30 @@
 tst hello_world.py:[LINENR]: two  [test_suite↪hello_world.py:[LINENR]]
 tst hello_world.py:[LINENR]: three  [test_suite↪hello_world.py:[LINENR]]
 tst hello_world.py:[LINENR] PASS  [test_suite↪hello_world.py]
-pass: all 1 tests passed.
+tst test_suite: PASS
+pass: all 6 tests passed (5 skipped).
 
 - a test with an error
 tst test_suite: Suite run start  [suite.py:[LINENR]]
 tst test_error.py:[LINENR] START  [test_suite↪test_error.py]  
[suite.py:[LINENR]]
 tst test_error.py:[LINENR]: I am 'test_suite' / 'test_error.py:[LINENR]'  
[test_suite↪test_error.py:[LINENR]]  [test_error.py:[LINENR]]
-tst test_error.py:[LINENR]: FAIL  [test_suite↪test_error.py:[LINENR]]  
[suite.py:[LINENR]]
-tst test_error.py:[LINENR]: ERR: AssertionError:   
[test_suite↪test_error.py:[LINENR]]  [test_error.py:[LINENR]: assert False]
-FAIL: 1 of 1 tests failed:
-  test_error.py
+tst test_error.py:[LINENR]: ERR: AssertionError:   [test_error.py:[LINENR]: 
assert False]
+tst test_error.py:[LINENR] FAIL (AssertionError)  [test_suite↪test_error.py]  
[suite.py:[LINENR]]
+tst test_suite: FAIL  [suite.py:[LINENR]]
+
+- a test with a failure
+tst test_suite: Suite run start  [suite.py:[LINENR]]
+tst test_fail.py:[LINENR] START  [test_suite↪test_fail.py]  [suite.py:[LINENR]]
+tst test_fail.py:[LINENR]: I am 'test_suite' / 'test_fail.py:[LINENR]'  
[test_suite↪test_fail.py:[LINENR]]  [test_fail.py:[LINENR]]
+tst test_fail.py:[LINENR] FAIL (EpicFail)  [test_suite↪test_fail.py]  
[suite.py:[LINENR]]
+tst test_suite: FAIL  [suite.py:[LINENR]]
+
+- a test with a raised failure
+tst test_suite: Suite run start  [suite.py:[LINENR]]
+tst test_fail_raise.py:[LINENR] START  [test_suite↪test_fail_raise.py]  
[suite.py:[LINENR]]
+tst test_fail_raise.py:[LINENR]: I am 'test_suite' / 
'test_fail_raise.py:[LINENR]'  [test_suite↪test_fail_raise.py:[LINENR]]  
[test_fail_raise.py:[LINENR]]
+tst test_fail_raise.py:[LINENR]: ERR: Failure: ('EpicFail', 'This failure is 
expected')  [test_fail_raise.py:[LINENR]: raise Failure('EpicFail', 'This 
failure is expected')]
+tst test_fail_raise.py:[LINENR] FAIL (EpicFail)  
[test_suite↪test_fail_raise.py]  [suite.py:[LINENR]]
+tst test_suite: FAIL  [suite.py:[LINENR]]
 
 - graceful exit.
diff --git a/selftest/suite_test.py b/selftest/suite_test.py
index 315c683..16342c5 100755
--- a/selftest/suite_test.py
+++ b/selftest/suite_test.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 import os
 import _prep
-from osmo_gsm_tester import log, suite, config
+from osmo_gsm_tester import log, suite, config, report
 
 config.ENV_CONF = './suite_test'
 
@@ -22,13 +22,33 @@
 print('- run hello world test')
 s = suite.SuiteRun(None, 'test_suite', s_def)
 results = s.run_tests('hello_world.py')
-print(str(results))
+print(report.suite_to_text(s))
 
 log.style_change(src=True)
 #log.style_change(trace=True)
 print('\n- a test with an error')
 results = s.run_tests('test_error.py')
-print(str(results))
+output = report.suite_to_text(s)
+assert 'FAIL: [test_suite] 1 failed ' in output
+assert 'FAIL: [test_error.py]' in output
+assert "type:'AssertionError' message: AssertionError()" in output
+assert 'assert False' in output
+
+print('\n- a test with a failure')
+results = s.run_tests('test_fail.py')
+output = report.suite_to_text(s)
+assert 'FAIL: [test_suite] 1 failed ' in output
+assert 'FAIL: [test_fail.py]' in output
+assert "type:'EpicFail' message: This failure is expected" in output
+assert "test.set_fail('EpicFail', 'This failure is expected')" in output
+
+print('\n- a test with a raised 

[PATCH] osmo-gsm-tester[master]: Add JUnit XML reports; refactor test reporting

2017-05-19 Thread Pau Espin Pedrol
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2669

to look at the new patch set (#6).

Add JUnit XML reports; refactor test reporting

* Add Junit output file support
* Differentiate between an expected failure test and an error in the
test, as described in JUnit.
* In case of an error/exception during test, record and attach it to the
Test object and continue running the tests, and show it at the end
during the trial report.

Change-Id: Iedf6d912b3ccea187a4ac6d5c6b70fe9d5c5
---
M .gitignore
M selftest/suite_test.ok
M selftest/suite_test.py
A selftest/suite_test/test_suite/test_fail.py
A selftest/suite_test/test_suite/test_fail_raise.py
M selftest/trial_test.ok
M src/osmo-gsm-tester.py
A src/osmo_gsm_tester/report.py
M src/osmo_gsm_tester/suite.py
M src/osmo_gsm_tester/test.py
M src/osmo_gsm_tester/trial.py
A suites/debug/error.py
M suites/debug/fail.py
A suites/debug/fail_raise.py
A suites/debug/pass.py
15 files changed, 293 insertions(+), 91 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/69/2669/6

diff --git a/.gitignore b/.gitignore
index 4119e7f..1ab84d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@
 test_work
 state
 *.pyc
+selftest/trial_test/
diff --git a/selftest/suite_test.ok b/selftest/suite_test.ok
index fda77dc..30c6915 100644
--- a/selftest/suite_test.ok
+++ b/selftest/suite_test.ok
@@ -59,15 +59,30 @@
 tst hello_world.py:[LINENR]: two  [test_suite↪hello_world.py:[LINENR]]
 tst hello_world.py:[LINENR]: three  [test_suite↪hello_world.py:[LINENR]]
 tst hello_world.py:[LINENR] PASS  [test_suite↪hello_world.py]
-pass: all 1 tests passed.
+tst test_suite: PASS
+pass: all 6 tests passed (5 skipped).
 
 - a test with an error
 tst test_suite: Suite run start  [suite.py:[LINENR]]
 tst test_error.py:[LINENR] START  [test_suite↪test_error.py]  
[suite.py:[LINENR]]
 tst test_error.py:[LINENR]: I am 'test_suite' / 'test_error.py:[LINENR]'  
[test_suite↪test_error.py:[LINENR]]  [test_error.py:[LINENR]]
-tst test_error.py:[LINENR]: FAIL  [test_suite↪test_error.py:[LINENR]]  
[suite.py:[LINENR]]
-tst test_error.py:[LINENR]: ERR: AssertionError:   
[test_suite↪test_error.py:[LINENR]]  [test_error.py:[LINENR]: assert False]
-FAIL: 1 of 1 tests failed:
-  test_error.py
+tst test_error.py:[LINENR]: ERR: AssertionError:   [test_error.py:[LINENR]: 
assert False]
+tst test_error.py:[LINENR] FAIL (AssertionError)  [test_suite↪test_error.py]  
[suite.py:[LINENR]]
+tst test_suite: FAIL  [suite.py:[LINENR]]
+
+- a test with a failure
+tst test_suite: Suite run start  [suite.py:[LINENR]]
+tst test_fail.py:[LINENR] START  [test_suite↪test_fail.py]  [suite.py:[LINENR]]
+tst test_fail.py:[LINENR]: I am 'test_suite' / 'test_fail.py:[LINENR]'  
[test_suite↪test_fail.py:[LINENR]]  [test_fail.py:[LINENR]]
+tst test_fail.py:[LINENR] FAIL (EpicFail)  [test_suite↪test_fail.py]  
[suite.py:[LINENR]]
+tst test_suite: FAIL  [suite.py:[LINENR]]
+
+- a test with a raised failure
+tst test_suite: Suite run start  [suite.py:[LINENR]]
+tst test_fail_raise.py:[LINENR] START  [test_suite↪test_fail_raise.py]  
[suite.py:[LINENR]]
+tst test_fail_raise.py:[LINENR]: I am 'test_suite' / 
'test_fail_raise.py:[LINENR]'  [test_suite↪test_fail_raise.py:[LINENR]]  
[test_fail_raise.py:[LINENR]]
+tst test_fail_raise.py:[LINENR]: ERR: Failure: ('EpicFail', 'This failure is 
expected')  [test_fail_raise.py:[LINENR]: raise Failure('EpicFail', 'This 
failure is expected')]
+tst test_fail_raise.py:[LINENR] FAIL (EpicFail)  
[test_suite↪test_fail_raise.py]  [suite.py:[LINENR]]
+tst test_suite: FAIL  [suite.py:[LINENR]]
 
 - graceful exit.
diff --git a/selftest/suite_test.py b/selftest/suite_test.py
index 315c683..16342c5 100755
--- a/selftest/suite_test.py
+++ b/selftest/suite_test.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 import os
 import _prep
-from osmo_gsm_tester import log, suite, config
+from osmo_gsm_tester import log, suite, config, report
 
 config.ENV_CONF = './suite_test'
 
@@ -22,13 +22,33 @@
 print('- run hello world test')
 s = suite.SuiteRun(None, 'test_suite', s_def)
 results = s.run_tests('hello_world.py')
-print(str(results))
+print(report.suite_to_text(s))
 
 log.style_change(src=True)
 #log.style_change(trace=True)
 print('\n- a test with an error')
 results = s.run_tests('test_error.py')
-print(str(results))
+output = report.suite_to_text(s)
+assert 'FAIL: [test_suite] 1 failed ' in output
+assert 'FAIL: [test_error.py]' in output
+assert "type:'AssertionError' message: AssertionError()" in output
+assert 'assert False' in output
+
+print('\n- a test with a failure')
+results = s.run_tests('test_fail.py')
+output = report.suite_to_text(s)
+assert 'FAIL: [test_suite] 1 failed ' in output
+assert 'FAIL: [test_fail.py]' in output
+assert "type:'EpicFail' message: This failure is expected" in output
+assert "test.set_fail('EpicFail', 'This failure is expected')" in output
+
+print('\n- a test with a raised 

osmo-gsm-tester[master]: Add JUnit XML reports; refactor test reporting

2017-05-19 Thread Pau Espin Pedrol

Patch Set 4:

(3 comments)

https://gerrit.osmocom.org/#/c/2669/4/src/osmo_gsm_tester/suite.py
File src/osmo_gsm_tester/suite.py:

Line 32: def __init__(self, fail_type='', fail_msg=''):
> * what exactly is the fail_type? is it junit specific? let's document here,
fail_type is just a keyword to define the type of failure, same as in you have 
types of errors or exceptions. JUNit report makes use of this on the output for 
instance.

I will make the parameters mandatory then.


Line 123: fmsg =  e.fail_msg + '\n' + 
traceback.format_exc().rstrip()
> (double space but whatever)
OK


Line 144: def set_fail(self, fail_type='', fail_message='', tb=True):
> (again require args instead of default-empty?)
OK


-- 
To view, visit https://gerrit.osmocom.org/2669
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Iedf6d912b3ccea187a4ac6d5c6b70fe9d5c5
Gerrit-PatchSet: 4
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 
Gerrit-HasComments: Yes


osmo-bts[master]: osmo-bts-trx: use libosmocoding

2017-05-19 Thread Max

Patch Set 2:

> We don't need this test

I know, but it's better to remove it in separate commit to make sure that 
migration does not introduce any regressions.

-- 
To view, visit https://gerrit.osmocom.org/2674
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I1b41bb1a8de655639107ec1f3b75afc240fd316f
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


libosmocore[master]: tests/Makefile.am: do not test disabled features

2017-05-19 Thread Max

Patch Set 1: Code-Review+1

-- 
To view, visit https://gerrit.osmocom.org/2682
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Iebcc24b493092a5a8e3561d7642a0b4608a8beae
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-HasComments: No