Android.mk hack for compiling libxml with schemas enabled

The "Schema" feature is enabled in the official libxml2.
We use that feature to validate the xml files given to the
parameter-framework.
In the libxml2 aosp version, this feature is not enabled.

This patch adds a new target, libxml2-schemas, which contains the
"Schemas" feature.

This should be removed when the "Schema" feature is integrated into the
aosp's libxml2 version.

Change-Id: Ida72de36e7fd196063a332ee70b30c0f0cb69024
Signed-off-by: David Wagner <david.wagner@intel.com>
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Added possibility to toggle xml validation

BZ: 184054

It was not possible to enable/disable xml file validation.
The parameter framework only relied on the LIBXML_SCHEMAS flag.

This patchs implements a new constructor for XmlFiles
which allows enabling/disabling xml/xsd check.

Change-Id: I32d220a42bb27f4ce685f07cb194e78e76f44a5d
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Test-platform enable/disable xml validation

BZ: 184054

test-platform has no way to tell to the parameter
framework that it wants the parameter framework to
validate xmls on loading.

New command added to test-platform executable.
setValidateSchemasOnStart true|false
    If set to true, the parameter framework will try
    to validate the .xmls with the .xsds located next to them.
    If set to false, it will never attempt to validate.

SetValidateSchemas is false by default to allow backward compatibility.

Note(a): This assumes that the script is able to
find the .xsd files (which should be in /tmp/Schemas/).

Change-Id: I7a5b0bc09d31e6647d8c631380d31503666e7e7b
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Fix KW10 issues

BZ: 186081

Due to upgrade klocwork (KW version from 9.6 to 10.0)
new issues have been raised.

This patch fix the new issues raised in PFW.

Change-Id: I54c14e4d6da1c9a5f8d82aec1769a9e7e948db50
Signed-off-by: Eduardo Mendi <eduardox.mendi@intel.com>
Add log in case of failure

BZ: 189977

The hostDomainGenerator.sh script generates xml files a build time.
Sometimes it fails but the log information are no sufficient to found
the root cause.

Add some log information in order to be able to find it.

Change-Id: I505577ee30503dccf25375b0ea262461ec4cce14
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Added copying of xsd files to host build output

BZ: 188323

In order to validate the .xml parameter framework files, we use XSDs.
Those must be in the same directory as the .xml files when they
are validated.

This patch copies the .xsd files towards a directory that
hostDomainGenerator knows, so that he can use the files and
copy them towards /tmp.

Change-Id: I938fc3791006777ff65c96d4259596111f93d7b8
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Fix xmlserializer makefile for schema validation

BZ: 188323

For schema validation features, we are using a special version of libxml2 called
libxml2-schemas (which contains the SCHEMAS feature).
This is just a different static library build with that feature only for
the parameter-framework.
The problem with that, is that the include/xmlversion.h does not
define the #LIBXML_SCHEMAS_ENABLED flag.
So when including it in our project, the flag is not defined.
This results in unexpected behaviour since validation was active in the
static library, but never called because the flag was not defined.

As a fix, we are defining the LIBXML_SCHEMAS_ENABLED flag in the makefile.

Change-Id: Id56ae5b668e587171b11e7607f2603ab5e3341a1
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Updated hostDomainGenerator.sh schema validation

BZ: 188323

In order to validate xml files, we need the corresponding schemas to be
next to the xml files. Those are put by the script in /tmp.

This patch add the copying of the schema files to /tmp.
I also adds an optional command line argument to disable/enable validation.
This is useful for platform specific enabling/disabling validation.
It can be used by calling hostDomainGenerator.sh --validate.

Change-Id: I7da65f230e5abf5b1d18c5cd6cf11b67dae5ed76
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
FixedPointParameterType: fix potential compilation issue

BZ: 176178

The isEncodable() method has several prototypes and some compilers are not able
to decide which version to use and produce a compilation error.

Remove unnecessary casts and make the code simpler by using a template-based
conversion library from string to various numeric types instead of using
strtoll and strtod.

Change-Id: I53d0b4ebd12f2cbb315bb52d98365a35876b5aef
Signed-off-by: David Wagner <david.wagner@intel.com>
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Correct FixedPointParameter display precision

BZ: 176178

Explain the precision computation (m * log10(2)):

  For a Qn.m number, the step between each storable number is 2^(-m).
  Hence, on a decimal representation, the Dth digit after the decimal
  point can take all possible values (1..9) - meaning that it is
  significant - only if

          2^(-m) <= 10^(-D)
              -m <= log2(10^(-D))
              -m <= log10(10^(-D)) / log10(2)
              -m <= -D / log10(2)
    m * log10(2) >= D

  Conversly, the Dth digit can be represented if

    D <= m * log10(2)

We add 1 to the precision in order to display the digit right after the last
significant digit.  This will lead to oddities such as:

    $ setParameter /Test/test/f32_Q8.23 0.1234569
    $ getParameter /Test/test/f32_Q8.23
    > 0.1234570

but it will avoid modifying raw values when converting from string to Q-format
and back to string.

Also, use std::setprecision() on the stream instead of manually truncating the
displayed number.

Change-Id: Ief2a7daabf4505ae4312e79036b0374f53368cac
Signed-off-by: David Wagner <david.wagner@intel.com>
Fix Fixed Point convert issue.

BZ: 185336

Convert is failing when trying to convert the string value
to integer value within FixedPointParameterType class.

This patch fixes the issue by requesting to convert the string
into a signed type.

Change-Id: I77987eb1564292bd6dcdd0da4db52c4b4f92818f
Signed-off-by: Francois Gaffie <francois.gaffie@intel.com>
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Remote-processor send returning 0 is not an error

BZ: 190038

Send can return a 0 size, it is normal.

Does not consider send return value 0 as an error.

Change-Id: Ic4801908b0771d5e0aba8c090fb9e9949d6e16fc
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Remote-processor continue on EINTR

BZ: 190038

EINTR is a normal error and should not fail recv or send.

Continue if those errors are received.

Change-Id: I66416153eb432b8f7daf97119c7c59c87e88da08
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
[remote-processor] Add context information on failure

BZ: 190038

Remote processor was not displaying information in case of network
read/write error.

Add some error messages to ease debug.

Change-Id: I465062e8cf77f94b3d4d4d0c71338c4630aac276
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
remote-proccessor detect partial message reception

BZ: 190038

Client disconnection during message reception is normal if no part of the
message as been receive yet.
Client disconnection in the middle of a packet reception is not normal
but was not differentiated from the behaviour described above.

Do not consider client disconnection on first read as an error.
Consider it as an error on the followings.

Change-Id: I34b50ba0af800f9e1fcdb51996b1b2f02a23cb3f
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
FixedPointParameter: Removed precision notion

BZ: 197723

Significant digits were computed in order to prevent odd behaviour when printing
a converted fixed point parameter. After converting a number from fixed
point towards a double, we had to round up/down in order to print the
double to the user (or towards a file).
The printing showed only the significant digits, in other words, the
digits which can vary from 0 to 9. This caused unpredictable behaviour
when rounding using the setPrecision() function.

This patch removes the 'precision' notion related to fixed points in
order to have a predictable behaviour by displaying all fractional
digits.

Change-Id: Id5a9b5b8a80d5a96bcbbb6af9213770a05a70083
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Fix fixed-point parameter range check

BZ: 197723

When adding parameters which are far out of bounds, the range check does
not refuse to set the value. This is unexpected behaviour.

This patch adds a correct range check.

Change-Id: I325920bcabc9485bd8f95aadcaff36a67182b97c
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
FixedPointParameter: Rename conversion functions

BZ: 197723

Give a few functions more meaningful names.
Add some cast fixes and doxygen to the renamed functions.

Change-Id: I002a3fa9b397294153c23b9883c3ad3b1c136e54
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Fixed point test configuration

BZ: 197723

This contains the configuration files which contains a lot of fixedpoint
parameters which can be used for testing.

Change-Id: I261120d16eb6f4d28b6b61a5b2845f1fdc18e91f
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Fixed point test script

BZ: 197723

This python script performs several checks on fixed point parameters:

- Bound check: Can we set a value?
- Sanity check: If we get this previously set parameter, is the
  value approximately the same? There should be at maximum a
  quantum difference between the original value and the returned value.
- Consistency check: Can we set the value we got from the sanity check?
- Bijectivity check: If we get the parameter we set a second time,
  is the result the same as the value we got from the set we did in the
  Sanity check?

Change-Id: I7b4d61ec740139b0ee70a44b6b38009507a569ee
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>