Commit graph

41 commits

Author SHA1 Message Date
Christopher Friedt
72e7debca5 tests: posix: tests for nanosleep(2)
This commit provides test-cases for nanosleep(2)

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-06-12 17:02:03 +02:00
Kumar Gala
a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Marc Herbert
debade9121 tests: make find_package(Zephyr...) REQUIRED
... because it is (required).

This makes a difference when building with CMake and forgetting
ZEPHYR_BASE or not registering Zephyr in the CMake package registry.

In this particular case, REQUIRED turns this harmless looking log
statement:

-- Could NOT find Zephyr (missing: Zephyr_DIR)
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- ...
-- ...
-- ...
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:8 (target_sources):
  Cannot specify sources for target "app" which is not built by
  this project.

... into this louder, clearer, faster and (last but not least) final
error:

CMake Error at CMakeLists.txt:5 (find_package):
  Could not find a package configuration file provided by "Zephyr" with
  any of the following names:

    ZephyrConfig.cmake
    zephyr-config.cmake

  Add the installation prefix of "Zephyr" to CMAKE_PREFIX_PATH or set
  "Zephyr_DIR" to a directory containing one of the above files.  If
  "Zephyr" provides a separate development package or SDK, be sure it
  has been installed.

-- Configuring incomplete, errors occurred!

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-05-29 10:47:25 +02:00
Paul Sokolovsky
b07489614f tests: posix: clock: Workaround to align clocks before querying
Before calling clock_gettime() 2 times in row, issue k_usleep(1)
to align code execution to timer interrupt to prevent (well,
minimize) possibility of getting different ticks values.

Suggested by @andyross.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2020-05-08 17:31:45 +02:00
Paul Sokolovsky
a61f86ea8e tests: posix: common: Switch k_sleep() -> k_msleep().
As a step in migration to new timeout API.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2020-05-08 17:31:45 +02:00
Torsten Rasmussen
407b49b35c cmake: use find_package to locate Zephyr
Using find_package to locate Zephyr.

Old behavior was to use $ENV{ZEPHYR_BASE} for inclusion of boiler plate
code.

Whenever an automatic run of CMake happend by the build system / IDE
then it was required that ZEPHYR_BASE was defined.
Using ZEPHYR_BASE only to locate the Zephyr package allows CMake to
cache the base variable and thus allowing subsequent invocation even
if ZEPHYR_BASE is not set in the environment.

It also removes the risk of strange build results if a user switchs
between different Zephyr based project folders and forgetting to reset
ZEPHYR_BASE before running ninja / make.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-27 16:23:46 +01:00
Paul Sokolovsky
79a58ddffa tests: posix: pthread: Clean up test for pthread_getname/setname_np
Recently added test for pthread_getname_np()/pthread_setname_np()
functions used uninitialized array value. As we can't check behavior
for arbitrary uninitialized value, but at most NULL value, make the
test calls to explicitly use NULL, to make the test intent clear
(instead of for example initializing the original array with zeros).

Also, these test cases use variable names not consistent with Zephyr
codestyle, and named to generically to cause confuse when used in a
general context of the test_posix_pthread_execution() function, so
rename them to be specific. (And alternative would be to separate
pthread_getname_np()/pthread_setname_np() tests into a separate
function, but it was indeed practical to piggyback them on existing
test_posix_pthread_execution()).

Fixes: #23473

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2020-03-23 12:48:20 -04:00
Nicholas Lowell
17b19eb810 pthread: add setname/getname glibc extensions
Adding the ability to set and get pthread names by defining
some non-standard extension functions that were first
introduced by Glibc.

Similar to zephyr thread naming, these allow for thread
tracking and debugging even when using the more portable
posix API.

Though Glibc was the originator, the current POSIX functions
have return codes based on Oracle's adopted spec, so these
functions follow suit.  The Oracle and Glibc function
prototypes match.

Signed-off-by: Nicholas Lowell <nlowell@lexmark.com>
2020-03-10 15:15:34 +02:00
Maksim Masalski
813ef68554 tests: updated names for the tests
Some test cases have the same test case name.
To get rid of it, I decided to change test cases names
contained same names.
Please check my logic, how I give them names.
Usually trying to give name same as a directory folder.
There are still more test cases which necessary to change,
but I will make changes by small steps.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2019-10-23 23:15:41 -04:00
Maksim Masalski
11faaacd1e tests/posix/common: Fix miscalibrated timing test
This test seems a little confused.
Adjust the calibration to allow 110ms sleeps to avoid error
during automated testing.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2019-10-23 14:45:40 +02:00
Charles E. Youse
f914669075 tests/posix/common: restructure to eliminate casts
Restructure code to reduce the number of obnoxious casts.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-09-15 11:33:47 +08:00
Charles E. Youse
2e788040d8 tests/posix/common: make 64-bit clean
Use the INT_TO_POINTER() and companion macros to silence compiler
warnings about casting between pointers and ints of different sizes.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-09-15 11:33:47 +08:00
Paul Sokolovsky
16c1db9b8f tests: posix: No longer use target_include_directories
This is no longer needed after using
zephyr_interface_library_named cmake directive in the POSIX subsys
source itself.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-08-08 14:31:35 +02:00
Paul Sokolovsky
b7bb48eeac posix: unistd.h: open() doesn't belong here
Per POSIX, open() is defined in <fcntl.h>. fcntl.h in turn comes from
the underlying libc, either newlib, or minimal libc.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-07-25 13:50:58 -04:00
Andy Ross
ffb9e0977d tests/posix/common: Adjust miscalibrated timing test
This test seems a little confused.  It does a POSIX usleep() for 90ms,
then checks the time taken, and verifies that it was no less
than... 91ms!

On existing platforms, tick alignment makes sure that we always take a
little longer, so this passes. But on high tick rate configurations we
get it exactly right.  And fail.

Adjust the calibration to allow (exactly) 90ms sleeps.  Also fixed a
comment that described the wrong units.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-07-02 22:52:29 -04:00
Anas Nashif
9ab2a56751 cleanup: include/: move misc/printk.h to sys/printk.h
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Marc Herbert
4afcc0f8af sanitycheck: CONFIG_TEST_USERSPACE / userspace tag cleanup
- Delete CONFIG_TEST_USERSPACE=n no-ops because it's the default
since commit 7b1ee5cf13

- Some tests have a "userspace" tag pretending to TEST_USERSPACE but
don't and vice versa: fix missing or spurious "userspace" tags in
testcase.yaml files.

Tests have a _spurious_ "userspace" tag when they PASS this command
cause none should pass:

  ./scripts/sanitycheck --tag=userspace -p qemu_x86 \
      --extra-args=CONFIG_TEST_USERSPACE=n  \
      --extra-args=CONFIG_USERSPACE=n | tee userspace.log

All tests run by this command must either fail to build or fail to run
with some userspace related error. Shortcut to look at all test
failures:

 zephyr_failure_logs() {
     awk '/see.*log/ {print $2}' "$@"
 }

Tests _missing_ "userspace" tag FAIL to either build or to run with some
userspace related error when running this:

  ./scripts/sanitycheck --exclude=userspace -p qemu_x86 \
      --extra-args=CONFIG_TEST_USERSPACE=n  \
      --extra-args=CONFIG_USERSPACE=n | tee excludeuserspace.log

Note the detection methods above are not 100% perfect because some
flexible tests like tests/kernel/queue/src/main.c evade them with #ifdef
CONFIG_USERSPACE smarts. Considering they never break, it is purely the
test author's decision to include or not such flexible tests in the
"userspace" subset.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-05-30 08:45:39 -04:00
Paul Sokolovsky
81fa697f32 posix: Move gettimeofday declaration to <sys/time.h>
According to POSIX, that's the header which defines this function.
Similarly, nothing in POSIX indicates that <time.h> should have
access to struct timeval, so it's removed (it's made accessible
to <sys/time.h> via <sys/_timeval.h> introduced earlier).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-05-07 22:18:09 -04:00
Andrew Boie
7387b56c61 tests: add nsim special cases for two tests
The NSIM emulator has severe performance issues when
the MPU registers are reprogrammed on context switch.
Disable runtime reprogramming of the MPU for these
platforms on these two tests, which have a lot of context
switch thrashing. This is done by ensuring userspace
and hardware stack overflow detection via guard areas
is disabled.

I have assurances from the ARC team that the tests run fine
on real hardware and this is an emulation issue.

For 1.15, this will be completely resolved by optimizing
MPU region gap-filling to not take place during context
switch time, which will drastically reduce the number of
MPU registers poked during context switch on nsim_sem.

Meanwhile, for 1.14 we ensure that no runtime reprogramming
of the MPU is done for these tests.

Fixes: #14642

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-09 19:38:32 -04:00
Anas Nashif
3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Patrik Flykt
21358baa72 all: Update unsigend 'U' suffix due to multiplication
As the multiplication rule is updated, new unsigned suffixes
are added in the code.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Patrik Flykt
24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Charles E. Youse
3522e05f76 posix/pthreads: fix pthread_barrier_wait() behavior to match Posix
Exactly one caller of pthread_barrier_wait() should receive a return
value of PTHREAD_BARRIER_SERIAL_WAIT; all others should receive zero
(or an error code). Added a test to match.

Fixes: #9953

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-03-02 03:40:06 +01:00
Andy Ross
a4614372f9 tests: Mass SMP disablement on non-SMP-safe tests
(Chunk 3 of 3 - this patch was split across pull requests to address
CI build time limitations)

Zephyr has always been a uniprocessor system, and its kernel tests are
rife with assumptions and outright dependence on single-CPU operation
(for example: "low priority threads will never run until this high
priority thread blocks" -- not true if there's another processor to
run it!)

About 1/3 of our tests fail right now on x86_64 when dual processor
operation is made default.  Most of those can probably be recovered on
a case-by-case basis with simple changes (and a few of them might
represent real bugs in SMP!), but for now let's make sure the full
test suite passes by turning the second CPU off.  There's still plenty
of SMP coverage in the remaining cases.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-02-27 14:22:06 -08:00
Kumar Gala
c894aa31a6 tests: posix: add newlib cfg option
Add a build variant of the posix tests with newlib enabled.  Since the
interation of posix is greatly related to the libc we should have these
tests build with and without newlib support.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-26 11:36:52 -06:00
Anas Nashif
69b6cc8956 Revert "tests: posix: add newlib cfg option"
This test is breaking CI, we need a fix first before we go and enable
tests.

This reverts commit dc39a9adcf.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-23 17:15:29 -05:00
Kumar Gala
dc39a9adcf tests: posix: add newlib cfg option
Add a build variant of the posix tests with newlib enabled.  Since the
interation of posix is greatly related to the libc we should have these
tests build with and without newlib support.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-23 11:42:31 -06:00
Kumar Gala
b730fa4ccb posix_lib: Disable support on native posix arch
For now we are disabling support for POSIX lib on native posix arch.  We
need to cleanup and support POSIX lib cleanly for hardware targets.
Once that is working properly we can look to support the feature on
native posix arch.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-22 11:55:01 -06:00
Anas Nashif
04743c9a79 posix: rename priority in sched_param struct
Priority member in the sched_param struct should be named
sched_priority.

Fixes #13470

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-19 11:24:45 -05:00
Andrew Boie
84c808918b tests: set CONFIG_MAX_THREAD_BYTES for a few tests
Some tests instantiate a lot of thread objects. These
were not tagged with __kernel, and
CONFIG_APPLICATION_MEMORY was enabled, so the kernel was
not adding them to the kernel object database.

However, with CONFIG_APPLICATION_MEMORY disabled, this
overflowed the default max number of thread objects (16).
Increase the max to 32 for these particular tests.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-08 07:04:30 -05:00
Andy Ross
3119d2973a tests/posix/common: Correct TEST_EXTRA_STACKSIZE usage
This is intended to be a value set by the platform to adjust the size
of stacks created by tests.  This test was setting it explicitly, and
failing to honor it when creating its own stacks.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-11 15:18:52 -05:00
Anas Nashif
5060ca6a30 cmake: increase minimal required version to 3.13.1
Move to latest cmake version with many bug fixes and enhancements.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-01-03 11:51:29 -05:00
Patrik Flykt
440b535602 tests: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Reto Schneider
7eabab2f5d samples, tests: Use semi-accurate project names
When using an IDE (e.g. Eclipse, Qt Creator), the project name gets
displayed. This greatly simplifies the navigation between projects when
having many of them open at the same time. Naming every project "NONE"
defeats this functionality.

This patch tries to use sensible project names while not duplicating
too much of what is already represented in the path. This is done by
using the name of the directory the relevant CMakeLists.txt file is
stored in. To ensure unique project names in the samples (and again, in
the tests folder) folder, small manual adjustments have been done.

Signed-off-by: Reto Schneider <code@reto-schneider.ch>
2018-10-27 21:31:25 -04:00
Spoorthi K
7fa2ec42ae tests: posix: Check for return values
Check for return value of pthread_attr_destroy().
Fixes: #10754

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-10-24 11:15:30 +01:00
Alberto Escolar Piedras
c6799dc7a1 tests: posix: Bugfix unitialized array in posix_pthread_execution
Initialize an otherwise unitialized array which was causing random
failures in tests/posix/common.

Fixes #10508

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-10-23 09:19:34 -07:00
Niranjhana N
11775b2247 tests: posix: enhance pthread test
Added negative tests to pthread APIs
to improve code coverage.

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2018-10-10 09:29:42 -04:00
Niranjhana N
81f835f27c tests: posix: group pthread tests
Grouped the five pthread tests into two -
pthread execution and pthread termination;
removed redundant tests.

Added the refactored tests and pthread_key
tests into the common folder.

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2018-10-10 09:29:42 -04:00
Spoorthi K
4c73b485c2 tests: POSIX: Enhance clock tests
Enhance clock test to validate gettimeofday() and
to improve line coverage.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-10-10 14:25:30 +02:00
Spoorthi K
dc8bbce357 tests: POSIX: Enhance semaphore tests
Enhance semaphore test to validate sem_timedwait()
    and sem_trywait(). This is intended to improve
    code coverage.

Also modify ztest check with zassert_equal with
return value instead of zassert_false for better
understandability.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-10-04 22:27:26 -04:00
Spoorthi K
11aa39bc25 tests: POSIX: Refactor POSIX API tests
Refactor and club the POSIX API tests into one test suite.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2018-10-04 22:27:26 -04:00