tests: Move to kernel style SPDX license identifiers
[lttng-tools.git] / tests / regression / tools / metadata / utils.sh
1 #!/bin/bash
2 #
3 # Copyright (C) 2019 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4 #
5 # SPDX-License-Identifier: LGPL-2.1-only
6
7 function get_env_value ()
8 {
9 local env_file=$1
10 local key=$2
11 local result
12 local ret
13
14 result=$(grep "$key" < "$env_file")
15 ret=$?
16 if [ $ret -eq 1 ]; then
17 echo "invalid_value_extraction"
18 return 1
19 else
20 # Strip the key using bash substring removal.
21 # This remove all leading chars until the actual value.
22 result=${result#* = }
23
24 # Remove the trailing ';'
25 result=${result:0:-1}
26
27 # Remove enclosing '"' if present
28 if [ "${result:0:1}" == '"' ]; then
29 result=${result:1:-1}
30 fi
31
32 echo "$result"
33 return 0
34 fi
35 }
36
37 function iso8601_to_lttng_dir_datetime ()
38 {
39 local result=$1
40
41 result=${result/T/-}
42
43 # Remove trailing timezone information including the '-'.
44 result=${result:0:-5}
45
46 echo "$result"
47 return 0
48 }
This page took 0.029548 seconds and 4 git commands to generate.