35 Commits

Author SHA1 Message Date
Mihai Tudor Panu
0a0c352614 tests: add missing license block on project python and node tests
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2020-03-05 15:14:11 -08:00
Mihai Tudor Panu
89d5de43e0 license: update to SPDX style license text throughout
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2020-03-05 15:13:36 -08:00
Mihai Tudor Panu
e3d054086b tests: reenable java blacklist until tinyb.java is formally integrated
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-04-11 12:04:28 -07:00
Mihai Tudor Panu
c0c37028e4 tests: use print function instead of statement
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-10-11 15:14:55 -07:00
Noel Eck
c2ce3e8222 gtest: Bump up to 3ms min-delay for CI
Much less stringent unit test for min timing delay.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-07-31 15:46:21 -07:00
Noel Eck
db3c73cbd1 utilities: Update time/r methods for LINUX
Default to MONOTONIC clock for timer methods to avoid falling victim to
clock corrections.  Changed signatures from accepting pointers since
this is not needed an complicates calls and Java/JS/Python bindings.

    * Switched from nanosleep to clock_nanosleep to allow developers to
      provide a clock for LINUX
    * Default upm_clock_init to CLOCK_MONOTONIC
    * Updated logic to calculating delay and elapsed to be more readable
    * Added ns flavors for completeness
    * Refactored all upm_* delay/timer methods
    * Added #else for preprocessor cases w/o an #else
    * Added test for AQI
    * Added test fixture with logic to identify a minimum delay time
      which is used as a metric for testing all delay methods
    * Much more lenient unit testing of delays to minimize false CI
      failures

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-07-31 14:20:30 -07:00
Noel Eck
be46240b8c gtest: Qualify nmea_gps test with nmea_gps target
Change the unit test CMakeLists to only build the nmea_gps unit test if
the nmea_gps target exists.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-07-30 10:05:07 -07:00
Noel Eck
ef81a20140 gtest: Added headers to unit tests
Added missing headers for the C++ unit tests.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-07-18 13:51:01 -07:00
Noel Eck
6228498147 nmea_gps: Added parsing TXT and bw calculations
Added code to parse GPTXT nmea sentences.  Added methods to calculate
sentences/second and raw bytes/second.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-05-25 15:51:13 -07:00
Noel Eck
3a077df5f6 nmea_gps: Update to handle parsing into structures
NMEA GPS class now uses threads to handle parsing NMEA sentences.
Currently only handles GGA, GSV, and GLL types.  Added queues for
holding parsed data.

    * Parsing thread
    * Parse GPS Fix from GGA and GLL
    * Parse satellite info from GSV
    * Provide a queue for GPS fix data as well as raw sentences
      (for debugging)
    * Target structures and NMEAGPS class have a __str__() method
      which summarizes the objects into a std::string.  These are
      tied to the __str__ method in python
    * Added google unit test for the above functionality

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-05-23 08:30:22 -07:00
Noel Eck
090ce2040e ctest: Add module path to sys path
Updated the pythonloader test module to always append the module's path
to the system path.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-03-15 11:10:00 -07:00
Noel Eck
76dd42a47d utilities_tests: Update us range for gtest
Be a bit more lenient with the acceptable range for the microsecond
flavor of upm_delay (+/- 150us instead of +/- 100us).

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-03-13 15:25:24 -07:00
Noel Eck
7254d5f75e gtest: Added custom target for all unit tests
Create a target which depends on all unit test executables for ease of
building/running.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-03-13 15:08:15 -07:00
Noel Eck
41e80d611e json: Added nlohmann's JSON C++ header
Adding JSON header for serializing/deserializing library descriptor JSON
files.

    * Added header
    * Added simple unit test to verify functionality

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-03-02 16:19:04 -08:00
Noel Eck
92b0919f56 gtest: Added Google Test
Added Google Test for unit testing.  Currently NOT required by UPM
CMake.

    * Added a test fixture for the utilities library.
    * Fixed bug in delay methods provided by utilities library.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-03-02 12:03:24 -08:00
Noel Eck
20aa4962f0 SWIG: Moved common SWIG syntax to ${libname}.i
This commit moves common SWIG syntax to a ${libname}.i for sensor
libraries.  Much of the swig content was originally duplicated for
each wrapper language which has lead to inconsistencies between wrappers
over time.  This commit moves all swig syntax to a common file.  Language
specific swig syntax can be added with #ifdef SWIG<LANGUAGE>.

The src/CMakeLists.txt will look first for a language-specific .i file,
then fall back to ${libname}.i.  In this way, it's possible to override
the common ${libname}.i file.  If a fallback .i file does NOT exist,
UPM CMake will generate a simple interface file for all languages.

Example:
    If no src/abp/pyupm_abp.i and no src/abp/abp.i then
    generate ${CMAKE_CURRENT_BINARY_DIR}/abp.i

When src/CMakeLists.txt uses a common ${libname}.i, it adds a -module
<language>upm_${libname} to the swig command line.

In the example below, a -module argument is provided for both Java and
Javascript, while the python module takes all syntax from pyupm_abp.i.

    SWIG FILE              Language       CMake added SWIG args
    ---------------        ----------     ---------------------
    src/abp/abp.i          java           -module javaupm_abp
    src/abp/abp.i          javascript     -module jsupm_abp
    src/abp/pyupm_abp.i    python

This commit removes ~4500 redundant lines for the UPM repository and
helps promote uniformity for the SWIG'ed languages.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-02-21 10:51:44 -08:00
Noel Eck
3d674efb51 CTest: Removed failing JSON lint test
Currently failing since a dependency has been deprecated.  Will enable
once a solution is in place.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-02-20 14:58:05 -08:00
Noel Eck
6725559669 JAVA: Remove library source compile from JAVA packages
Previously the JAVA packages re-compile UPM library source files.  This
was a work-around for compiling JAVA-specific functionality from the UPM
source into the SWIG'ed JAVA pacakges.

This commit removes the source from the JAVA SWIG compile and provides
an example on how to add the JAVA-specific code with a swig extend call.

    * Added _upm.i file for %import (not %include)
    * Added macros to _upm.i; 1 which performs the loadLibrary, and one
      which adds the java installISR runnable.
    * Updated the src/CMakeLists.txt file to NOT build library src into
      pacakges.
    * Updated the a110x library with examples on how to use the macros.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-01-24 09:30:23 -08:00
Noel Eck
bc4f124d54 sensortemplate: Use SensorTemplate as class name in json
Replace TemplateItem with SensorTemplate in the sensortemplate.json and
json ctest.  Change to contributions.md which removes all objects
with a key starting with "//" from the generated sensor .json file.
This allows the json ctest to pass OOTB for new sensor libraries
generated from the make_new_sensor function.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-11-02 13:21:27 -07:00
Abhishek Malik
303323fa3a JSON: Adding ctest
This commit adds node based tests provided by Nico to the ctest
framework already established in UPM.

Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-09-14 17:52:52 -07:00
Nicolas Oliver
0bf4a38f5e check for examples and images path
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-09-14 17:52:49 -07:00
Nicolas Oliver
e441c343d8 use sensortemplate.json metadata to test json files
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-09-14 17:52:47 -07:00
Nicolas Oliver
ef681a0ab5 add initial jsonlint and mocha test for json files
[ci skip]

Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-09-14 17:52:17 -07:00
Mihai Tudor Panu
0cb7d3f9b4 tests: harden tests for handling universal line endings
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 22:30:54 -07:00
sisinty sasmita patra
1f18369fbe SWIG_JAVA: C++ Interfaces to Java interfaces, Modified one Java Example
This commit translates C++ interfaces to Java interfaces, previously C++ Interfaces implemented java classes.

    * Added java swig interface files for all C++ interfaces to simplify swig
    javaupm_iADC.i
    javaupm_iCO2Sensor.i
    javaupm_iHumiditySensor.i
    javaupm_iLightController.i
    javaupm_iLightSensor.i
    javaupm_iModuleStatus.i
    javaupm_interfaces.i
    javaupm_iPressureSensor.i
    javaupm_iTemperatureSensor.i

    <example Usage>
        %include"../interfaces/javaupm_iADC.i"

    * Modified swig interface files for few sensors that implements interfaces
    ads1x15
    bmp280
    bmpx8x
    ds1808lc
    hlg150h
    lp8860
    max44009
    ms5611
    si1132
    si7005
    t6713

    * Removed few methods that were mentioned Protected and made them public, so that menthods can be overridden

    * Made IModuleStatus virtual to avoid ambiguity in multiple inheritance
    For example
    class A {};
    class B : public A {};
    class C : public A {};
    class D : public B, public C {};

    This can be solved as
    class A {};
    class B : virtual public A {};
    class C : virtual public A {};
    class D : public B, public C {};

    * Modified java interface files to support multiple swig versions

    * Modified javaupm interface file to support standard auto load library code

    * Fixed autoloadlibrary tests for interfaces

    * Created one interface example separately <BME280_InterfaceExample.java>,
    <example Usage>
        BME280_InterfaceExample.java
    since we cann't define swig versions inside java example file.
    So, instaed added swig versions in Cmake.
    <example Usage>
         if (SWIG_VERSION VERSION_GREATER 3.0.8)
           add_example_with_path(BME280_InterfaceExample bmp280 bmp280)
         endif()

Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2017-03-02 20:14:03 -08:00
Noel Eck
f8663c90f3 ctest: Fix for autoloadlibrary ctest
Update to fix a python indentation error.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-02-23 11:14:44 -08:00
Mihai Tudor Panu
bd8104f6ee tests: exclude build dir and update expected number of duplicates
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-02-09 16:49:27 -08:00
Mihai Tudor Panu
ddddbd024d tests: temporarily allow duplicate headers until cleanup
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-02-06 21:28:01 -08:00
Mihai Tudor Panu
67e0ceb48d tests: add test for duplicate headers
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-02-06 19:30:02 -08:00
Noel Eck
bf425014ab python: Added upm directory for python modules
* Grouped UPM python modules into upm directory, for example:
      /usr/local/lib/python2.7/dist-packages/upm
    * Updated UPM example import statements
    * Removed unused RPATH statements from UPM src CMakeLists.txt,
      currently build collateral contains an explicit RPATH which
      is stripped from the install collateral.
    * Converted python examples to work on both python2 AND python3
    * Added ctest for loading examples w/python3
    * Removed returns from swig macros
    * UPM python module use will change...
        Before:
            import pyupm_dfrph
        After:
            from upm import pyupm_dfrph
            or
            import upm.pyupm_dfrph
            etc...
    * This commit fixes #468

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-10-13 08:22:40 -07:00
Noel Eck
c6610bdf46 tests: Switch from PYTHON_EXECUTABLE to PYTHON_DEFAULT_EXECUTABLE
The DetectPython cmake script now outputs a default python executable.
Updated other cmake scripts to use this concept.  Used default where
python2/3 will work, use explicit PYTHON2/3_EXECUTABLE where an
explicit version is needed.  Also, fail if python is required and NO
version of python was found.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-10-05 17:12:02 -07:00
Noel Eck
edd8df4c50 encodings: Added check for non-8bit encodings in src tree.
This commit sanitizes source files for unicode encodings which
cause failures in downstream flows (docgen, python2 module loading,
etc...).

    * Removed explicit encodings from src files
    * Replaced 2 byte character encodings with ascii encodies:
        ± -> +/-
        ° -> deg
        “ -> "
        etc...
    * Added ctest to check src tree files for non-8bit encodings

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-10-05 14:39:30 -07:00
Noel Eck
131947dc74 check_pythonload: Updated assert print.
Print out failing files in order in a python3-friendly way.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-10-05 11:54:21 -07:00
Noel Eck
2f78d9f62b python_examples: Reformatted, self-checking, executable
* Moved body of each python example to main.  This allows for basic
      load module testing for CI
    * General cleanup of python modules (crlf/tabs/prints/etc)
    * Chmod'ed to 755 to allow running examples without specifying the
      python interpreter
    * Added ctest for loading python2/3 modules
    * Added jniclasscode pragma for java swig interface files.
    * Updated check_examplenames.py module to check all languages vs. a
      cxx example name
    * Added tests for checking python module and test loading
    * Added 'make test' to travis-ci run (run ctests)
    * Print a more meaningful message when not building cxx docs into
      python modules
    * Updated check_clean.py to only check java wrapper files
    * ENABLED ctests for UPM
    * Deleted using_carrays.py python example - this is covered by other
      examples

Signed-off-by: Noel Eck <noel.eck@intel.com>
2016-10-04 16:10:17 -07:00
Stefan Andritoiu
40f9135412 java: Added sanity checks and integrated them in CMake. Updated sample names and sample mapping.
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2016-01-28 16:13:37 -08:00