So, this is initial work is about creating functions that will validate
the output of more complex scenarios when using mixer. The
bat-mixer-extras.t holds a simple test as an example that this file will
hold more scenarios that will call upon mixerExtras.bash functions to
validate.
Initially on mixerExtras.bash function mixer_init evaluates files contents and folder
creation after
a mixer init. This function will grow to accept the other flags for mixer.
Signed-off-by: libertad Gonzalez de la Cruz <libertad.cruz(a)intel.com>
---
bundles/mixer/bat-mixer-extras.t | 47 +++++++++++++
src/mixer-extras/mixerExtras.bash | 109 ++++++++++++++++++++++++++++++
2 files changed, 156 insertions(+)
create mode 100644 bundles/mixer/bat-mixer-extras.t
create mode 100644 src/mixer-extras/mixerExtras.bash
diff --git a/bundles/mixer/bat-mixer-extras.t b/bundles/mixer/bat-mixer-extras.t
new file mode 100644
index 00000000..228f0dd6
--- /dev/null
+++ b/bundles/mixer/bat-mixer-extras.t
@@ -0,0 +1,47 @@
+#!/usr/bin/env bats
+# *-*- Mode: sh; c-basic-offset: 8; indent-tabs-mode: nil -*-*
+#
+#
+#
+# Mixer
+# -----------------
+#
+# Author : Libertad Gonzalez
+#
+# Requirements: bundle mixer
+#
+
+src_path="../../src/mixer-extras"
+
+load "$src_path"/mixerExtras
+
+
+setup() {
+ if ! systemctl is-active docker; then
+ ../../src/bat-kata-containers/set-up-docker-service.sh
+ fi
+ TMP_DIR=$(mktemp -d)
+ pushd "$TMP_DIR"
+}
+
+teardown() {
+ popd
+ rm -rf "$TMP_DIR"
+}
+
+
+@test "create minimal mix with different mix version" {
+
+ mix_version="--mix-version"
+ mixInt="13"
+ clear_version="--clear-version"
+ clStr="28000"
+ format="--format"
+ fStr="27"
+
+ mixer_init "$mix_version" "$mixInt" "$clear_version"
"$clStr" "$format" "$fStr"
+
+
+}
+
+
diff --git a/src/mixer-extras/mixerExtras.bash b/src/mixer-extras/mixerExtras.bash
new file mode 100644
index 00000000..f6566f67
--- /dev/null
+++ b/src/mixer-extras/mixerExtras.bash
@@ -0,0 +1,109 @@
+#!/usr/bin/sh
+# *-*- Mode: sh; c-basic-offset: 8; indent-tabs-mode: nil -*-*
+#
+# Mixer
+# -----------------
+#
+# Author : Libertad Gonzalez
+#
+# Requirements: bundle mixer
+#
+
+
+mixer_init () {
+
+ mix_version=$1 #holds the flag: --mix-version
+ mixInt=$2 #holds the int value for --mix-version flag
+ clear_version=$3 #holds the flag: --clear-version
+ clStr=$4 #holds the string value for --clear-version flag
+ format=$5 #holds the flag: --format
+ fStr=$6 #holds the string value for --format flag
+
+ cmd="$(mixer init $mix_version $mixInt $clear_version $clStr $format $fStr)"
+
+ if [ -z "$mixInt" ]; then
+ mixInt="10"
+ fi
+
+
+ echo $cmd | grep "Adding bundle \"os-core\"" |grep
"Adding bundle \"os-core-update\"" | grep "Adding bundle
\"bootloader\"" | grep "Adding bundle
\"kernel-native\"" | grep "Initializing mix version $mixInt"
+ if [ $? -eq 1 ]; then
+ exit 1
+ fi
+
+ check_file_content "bootloader|kernel-native|os-core|os-core-update"
"mixbundles"
+ check_file_content "$mixInt" "mixversion"
+
+ if [ ! -z $clStr ]; then
+ check_file_content "$clStr" "upstreamversion"
+ fi
+
+ if [ ! -z $fStr ]; then
+ check_file_content "FORMAT = \"$fStr\"" "mixer.state"
+ fi
+
+
+
+ touch mixer_created_directories
+ echo -e "local-bundles\nlocal-rpms\nlocal-yum\nupstream-bundles" >>
mixer_created_directories
+ file_dir_exists "mixer_created_directories" "-d"
+ rm mixer_created_directories
+
+ touch mixer_created_files
+ echo -e
"builder.conf\nmixbundles\nmixer.state\nmixversion\nupstreamurl\nupstreamversion"
>> mixer_created_files
+ file_dir_exists "mixer_created_files" "-f"
+ rm mixer_created_files
+
+ check_builder_conf
+
+}
+
+check_builder_conf () {
+
+ check_file_content "\[Builder\]" "builder.conf"
+ check_file_content "CERT = \"$(pwd)/Swupd_Root.pem\""
"builder.conf"
+ check_file_content "SERVER_STATE_DIR = \"$(pwd)/update\""
"builder.conf"
+ check_file_content "VERSIONS_PATH = \"$(pwd)\""
"builder.conf"
+ check_file_content "YUM_CONF = \"$(pwd)/.yum-mix.conf\""
"builder.conf"
+ check_file_content "\[Swupd\]" "builder.conf"
+ check_file_content "BUNDLE = \"os-core-update\""
"builder.conf"
+ check_file_content "CONTENTURL = \"<URL where the content will be
hosted>\"" "builder.conf"
+ check_file_content "VERSIONURL = \"<URL where the version of the mix
will be hosted>\"" "builder.conf"
+ check_file_content "\[Server\]" "builder.conf"
+ check_file_content "DEBUG_INFO_BANNED = \"true\""
"builder.conf"
+ check_file_content "DEBUG_INFO_LIB = \"/usr/lib/debug\""
"builder.conf"
+ check_file_content "DEBUG_INFO_SRC = \"/usr/src/debug\""
"builder.conf"
+ check_file_content "\[Mixer\]" "builder.conf"
+ check_file_content "LOCAL_BUNDLE_DIR = \"$(pwd)/local-bundles\""
"builder.conf"
+ check_file_content "LOCAL_REPO_DIR = \"$(pwd)/local-yum\""
"builder.conf"
+ check_file_content "LOCAL_RPM_DIR = \"$(pwd)/local-rpms\""
"builder.conf"
+ check_file_content "DOCKER_IMAGE_PATH = \"clearlinux/mixer\""
"builder.conf"
+
+
+}
+
+file_dir_exists () {
+
+ list=$1
+ flag=$2
+
+ while read -r dir_file; do
+ if [ "$flag" $dir_file ]; then
+ echo "$dir_file exists"
+ else
+ echo "$dir_file should exist, but does not."
+ exit 1
+ fi
+ done < $list
+
+
+}
+
+check_file_content () {
+
+ echo "we will check file content for $1 in $2"
+ egrep -w "$1" "$2"
+ if [ $? -eq 1 ]; then
+ exit 1
+ fi
+}
--
2.20.0
Show replies by date