zephyr/tests/kernel/context
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
..
src tests: skip the cpu_idle test for nsim_hs_smp 2020-05-26 17:47:42 +02:00
CMakeLists.txt tests: make find_package(Zephyr...) REQUIRED 2020-05-29 10:47:25 +02:00
README.txt tests: kernel: context: in README, fix text for k_cpu_idle testing 2020-03-23 12:10:46 -07:00
prj.conf tests: Never disable SMP 2019-09-26 16:54:06 -04:00
testcase.yaml Revert "test: kernel: context: Exclude for qemu_cortex_r5 (temporary)" 2020-05-19 17:14:18 +02:00

README.txt

Title: Context and IRQ APIs

Description:

This test verifies that the kernel CPU and context APIs operate as expected.


APIs tested in this test set
============================

k_thread_create
  - start a helper thread to help with k_yield() tests
  - start a thread to test thread related functionality

k_yield
  - Called by a higher priority thread when there is another thread
  - Called by an equal priority thread when there is another thread
  - Called by a lower priority thread when there is another thread

k_current_get
  - Called from an ISR (interrupted a task)
  - Called from an ISR (interrupted a thread)
  - Called from a task
  - Called from a thread

k_is_in_isr
  - Called from an ISR that interrupted a task
  - Called from an ISR that interrupted a thread
  - Called from a task
  - Called from a thread

k_cpu_idle
  - Tickless Kernel: CPU to be woken up by a kernel timer (k_timer)
  - Non-tickless kernel:
    CPU to be woken up by tick timer.  Thus, after each call, the tick count
    should have advanced by one tick.

irq_lock
  - 1. Count the number of calls to _tick_get_32() before a tick expires.
  - 2. Once determined, call _tick_get_32() many more times than that
       with interrupts locked.  Check that the tick count remains unchanged.

irq_unlock
  - Continuation irq_lock: unlock interrupts, loop and verify the tick
    count changes.

irq_offload
  - Used when triggering an ISR to perform ISR context work.

irq_enable
irq_disable
  - Use these routines to disable and enable timer interrupts so that they can
    be tested in the same way as irq_lock() and irq_unlock().

---------------------------------------------------------------------------

Building and Running Project:

This project outputs to the console.  It can be built and executed
on QEMU as follows:

    make run

---------------------------------------------------------------------------

Troubleshooting:

Problems caused by out-dated project information can be addressed by
issuing one of the following commands then rebuilding the project:

    make clean          # discard results of previous builds
                        # but keep existing configuration info
or
    make pristine       # discard results of previous builds
                        # and restore pre-defined configuration info

---------------------------------------------------------------------------

Sample Output:

tc_start() - Test kernel CPU and thread routines
Initializing kernel objects
Testing k_cpu_idle()
Testing interrupt locking and unlocking
Testing irq_disable() and irq_enable()
Testing some kernel context routines
Testing k_current_get() from an ISR and task
Testing k_is_in_isr() from an ISR
Testing k_is_in_isr() from a preemtible thread
Spawning a thread from a task
Thread to test k_current_get() and k_is_in_isr()
Thread to test k_yield()
Testing k_busy_wait()
Thread busy waiting for 20000 usecs
Thread busy waiting completed
Testing k_sleep()
 thread sleeping for 50 milliseconds
 thread back from sleep
Testing k_thread_create() without cancellation
 thread (q order: 2, t/o: 500) is running
 got thread (q order: 2, t/o: 500) as expected
 thread (q order: 3, t/o: 750) is running
 got thread (q order: 3, t/o: 750) as expected
 thread (q order: 0, t/o: 1000) is running
 got thread (q order: 0, t/o: 1000) as expected
 thread (q order: 6, t/o: 1250) is running
 got thread (q order: 6, t/o: 1250) as expected
 thread (q order: 1, t/o: 1500) is running
 got thread (q order: 1, t/o: 1500) as expected
 thread (q order: 4, t/o: 1750) is running
 got thread (q order: 4, t/o: 1750) as expected
 thread (q order: 5, t/o: 2000) is running
 got thread (q order: 5, t/o: 2000) as expected
Testing k_thread_create() with cancellations
 cancelling [q order: 0, t/o: 1000, t/o order: 0]
 thread (q order: 3, t/o: 750) is running
 got (q order: 3, t/o: 750, t/o order 1) as expected
 thread (q order: 0, t/o: 1000) is running
 got (q order: 0, t/o: 1000, t/o order 2) as expected
 cancelling [q order: 3, t/o: 750, t/o order: 3]
 cancelling [q order: 4, t/o: 1750, t/o order: 4]
 thread (q order: 4, t/o: 1750) is running
 got (q order: 4, t/o: 1750, t/o order 5) as expected
 cancelling [q order: 6, t/o: 1250, t/o order: 6]
PASS - main.
===================================================================
PROJECT EXECUTION SUCCESSFUL