Skip to content

Latest commit

 

History

History
 
 

unit_tests

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Unit testing using the GoogleTest framework

These tests were copied from https://github.com/alanxz/rabbitmq-c/tree/master/tests and converted to gtests.

Table of contents

Solution overview

List of programs

  • TestEntity—Tests
  • EntropyEntity—Random number generator
  • DNetSrv—Driver for working with network cards
  • VfsSdCardFs—Program that supports the SD Card file system
  • VfsNet—Program that is used for working with the network
  • Dhcpcd—DHCP client implementation program that gets network interface parameters from an external DHCP server in the background and passes them to the virtual file system
  • SDCard—SD Card driver
  • BSP—Driver for configuring pin multiplexing parameters (pinmux)
  • Bcm2711MboxArmToVc—Mailbox driver for Raspberry Pi 4 B

Initialization description

Statically created IPC channels
  • amqp.TestEntitykl.VfsSdCardFs
  • amqp.Consumerkl.VfsNet
  • kl.VfsNetkl.EntropyEntity
  • kl.VfsNetkl.drivers.DNetSrv
  • kl.rump.Dhcpcdkl.VfsSdCardFs
  • kl.rump.Dhcpcdkl.VfsNet
  • kl.VfsSdCardFskl.drivers.SDCard
  • kl.VfsSdCardFskl.EntropyEntity
  • kl.drivers.DNetSrvkl.drivers.Bcm2711MboxArmToVc
  • kl.drivers.SDCardkl.drivers.BSP

The ./einit/src/init.yaml.in template is used to automatically generate part of the solution initialization description file init.yaml. For more information about the init.yaml.in template file, see the KasperskyOS Community Edition Online Help.

Security policy description

The ./einit/src/security.psl.in template is used to automatically generate part of the security.psl file using CMake tools. The security.psl file contains part of a solution security policy description. For more information about the security.psl file, see Describing a security policy for a KasperskyOS-based solution.

⬆ Back to Top

Getting started

Building and running the tests

The tests for KasperskyOS are built using the CMake build system, which is provided in the KasperskyOS Community Edition SDK.

The SDK_PREFIX environment variables affects the build of the tests. It specifies the path to the installed version of the KasperskyOS Community Edition SDK.

Run the following command ./cross-build.sh <TARGET> [SDK_PATH], where:

  • TARGET can take one of the following values: qemu for QEMU or rpi for Raspberry Pi 4 B.
  • SDK_PATH specifies the path to the installed version of the KasperskyOS Community Edition SDK. If not specified, the path defined in the SDK_PREFIX environment variable is used. The value specified in the SDK_PATH option takes precedence over the value of the SDK_PREFIX environment variable.

QEMU

Running cross-build.sh creates a KasperskyOS-based solution image that includes the tests. The kos-qemu-image solution image is located in the ./build/einit directory.

The cross-build.sh script both builds the tests on QEMU and runs them.

Raspberry Pi 4 B

Running cross-build.sh creates a KasperskyOS-based solution image that includes the tests and a bootable SD card image for Raspberry Pi 4 B. The kos-image solution image is located in the ./build/einit directory. The rpi4kos.img bootable SD card image is located in the ./build directory.

  1. To copy the bootable SD card image to the SD card, connect the SD card to the computer and run the following command:

    $ sudo dd bs=64k if=build/rpi4kos.img of=/dev/sd[X] conv=fsync,

    where [X] is the final character in the name of the SD card block device.

  2. Connect the bootable SD card to the Raspberry Pi 4 B.

  3. Supply power to the Raspberry Pi 4 B and wait for the tests to run.

You can also use an alternative option to prepare and run the tests:

  1. Prepare Raspberry Pi 4 B and a bootable SD card to run the tests by following the instructions in the KasperskyOS Community Edition Online Help.
  2. Run the tests by following the instructions in the KasperskyOS Community Edition Online Help

CMake input files

./consumer/CMakeLists.txt—CMake commands for building the TestEntity program.

./einit/CMakeLists.txt—CMake commands for building the Einit program and the solution image.

./CMakeLists.txt—CMake commands for building the solution.

Usage

Once testing is complete, the results are displayed:

[==========] Running 5 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 5 tests from LibRabbitMQTest
[ RUN      ] LibRabbitMQTest.ParseUrl
[       OK ] LibRabbitMQTest.ParseUrl (4 ms)
[ RUN      ] LibRabbitMQTest.Tables
[       OK ] LibRabbitMQTest.Tables (8 ms)
[ RUN      ] LibRabbitMQTest.StatusEnum
[       OK ] LibRabbitMQTest.StatusEnum (1 ms)
[ RUN      ] LibRabbitMQTest.SaslMechanism
[       OK ] LibRabbitMQTest.SaslMechanism (0 ms)
[ RUN      ] LibRabbitMQTest.MergeCapabilities
[       OK ] LibRabbitMQTest.MergeCapabilities (2 ms)
[----------] 5 tests from LibRabbitMQTest (48 ms total)

[----------] Global test environment tear-down
[==========] 5 tests from 1 test suite ran. (69 ms total)
[  PASSED  ] 5 tests.

⬆ Back to Top

© 2024 AO Kaspersky Lab