Ctrl K
ComunidadGuías…

test/README.md

Rama master · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
# Gerbera Test

`PlaylistUpdateIntegration` additionally exercises a real Gerbera process on Linux
when JavaScript, inotify, Python 3 and TagLib or FFmpeg are available. It uses temporary generated WAV
files and M3U/M3U8/PLS/ASX playlists, checks both native playlist views through
ContentDirectory and downloads their complete resources. The sequence covers
read-only/writable close, media edits/replacement, playlist edits/repetitions,
rescans, restart, addition and deletion, with both `mt` and `grb` imports.
It does not use an existing library or configuration. A usable IPv4 network
interface is needed for the fixture's UPnP listener.

For a focused run with retained diagnostic files:

```sh
python3 test/content/test_playlist_updates.py --binary build/gerbera \
    --source-root "$PWD" --work-directory /tmp/grb-pl --debug
```

Use a fresh work directory for each run. Omit `--work-directory` for automatic
temporary-file cleanup.

`ShutdownDuringStartup` starts a real Gerbera process on Linux when Python 3 is
available and sends it SIGTERM as soon as the web server accepts a connection, three times. It fails
if the process is still running 20 seconds later. It uses a generated configuration and
database, and needs a usable IPv4 network interface for the UPnP listener.

This file outlines how the Gerbera system uses the **GoogleTest**
framework to provide unit testing for the C++ code-base.

`Corpus/XmlPlaylistTest` reports the 45 WPL/XSPF reader cases individually.
`ImportModes/XmlPlaylistImportTest` then imports the same corpus with the real
server and an isolated SQLite database for both `mt` and `grb`. It checks both
playlist views, mixed audio/video order, repeated positions, local and external
URIs, legacy formats and character set recovery, playlist refresh, two unchanged
rescans and restart. Each content check retains its 30-second deadline.
Separately named HTTP cases use the existing CurlIOHandler to compare complete
local resources byte for byte and never fetch external fixture URLs. Only those
HTTP cases are explicitly skipped when CURL is unavailable. The real corpus
import retains its Linux, JavaScript and FFmpeg prerequisites; no Python
process/readiness helper is added.

## Required Software

- CMake ^3.9
- GoogleTest

## Enable Testing

The CMake build enables testing using the `WITH_TESTS` flag

```text
$ cmake ../gerbera -DWITH_TESTS=1
```

## Running All Tests

Build the project and run all the tests

```
$ make && make test
```

The tests output looks similar to below:

```
Running tests...
Test project /development/gerbera/build
    Start 1: testdictionary
1/2 Test #1: testdictionary ...................   Passed    0.02 sec
    Start 2: testruntime
2/2 Test #2: testruntime ......................   Passed    0.02 sec

100% tests passed, 0 tests failed out of 2

Total Test time (real) =   0.05 sec

```

## Running Specific Test

You can run specific tests by using `ctest`. Below is an example of running the
**testdictionary** test only.


```
$ ctest -R testdictionary
Test project /development/gerbera/build
    Start 1: testdictionary
1/1 Test #1: testdictionary ...................   Passed    0.02 sec

100% tests passed, 0 tests failed out of 1

Total Test time (real) =   0.03 sec
```

## Creating a New Test

Adding a new test to Gerbera is easy.  The process amounts to a few steps:

1. Create a new feature test folder similar to `/test/test_myfeature`
2. Create `CMakeLists.txt` within your new folder.
3. Create a `main.cc` Google Test file
4. Add your files to your `CMakeLists.txt` within your `/test/test_myfeature` folder
4. Add sub-directory `test_myfeature` to the parent `/test/CMakeLists.txt` file