Initial commit

pull/1/head v0.1
Alexey Lyubimov 11 months ago
commit 5b2b38254c

@ -0,0 +1,10 @@
Тест osinfo-db на корректность распознавания ISO-образов MSVSphere утилитой osinfo-detect
Исходные ISO файлы загружаются из списка msvsphereiso.uri
При успешном завершении тест возвращает 0, при проблемах возвращается значение 1 и более.
Работа теста сопровождается выводом информационных сообщений поятняющих суть действий.
Для запуска теста необходимо проверить наличие корректных URL для загрузки ISO и CHECKSUM файлов и выполнить osinfo-detect-test.sh

@ -0,0 +1,92 @@
exitmsg()
{
echo "$1"
exit $2
}
cdcheck()
{
case $1 in
0)
echo "cd $2"
;;
1)
exitmsg "Error: cd $2, exiting..." 1
;;
*)
exitmsg "Error: cd $2 unknown error " $?
;;
esac
}
wgetcheck()
{
case $1 in
0)
echo "osinfo-detect-test.sh log: wget $2 No problems occurred."
;;
1)
exitmsg "Error: wget $2 Generic error code, exiting..." 1
;;
2)
exitmsg "Error: wget $2 Parse error---for instance, when parsing command-line options, the .wgetrc or .netrc..., exiting..." 2
;;
3)
exitmsg "Error: wget $2 File I/O error, exiting..." 3
;;
4)
exitmsg "Error: wget $2 Network failure, exiting..." 4
;;
5)
exitmsg "Error: wget $2 SSL verification failure, exiting..." 5
;;
6)
exitmsg "Error: wget $2 Username/password authentication failure, exiting..." 6
;;
7)
exitmsg "Error: wget $2 Protocol errors, exiting..." 7
;;
8)
exitmsg "Error: wget $2 Server issued an error response, exiting..." 8
;;
*)
exitmsg "Error: wget unknown error " $?
;;
esac
}
osinfodetectcheck()
{
case $1 in
0)
echo "Detecting completed successfully."
;;
1)
exitmsg "Error: Detecting comleted with error, exiting..." 1
;;
253)
exitmsg "Error: Internal test error (Error parsing media: Failed to open file:) when osinfo detecting, exiting..." 2
;;
*)
exitmsg "Error: osinfo-detect unknown error " $?
;;
esac
}
diffcheck()
{
case $1 in
0)
echo "Test completed successfully."
;;
1)
exitmsg "Error: Test unsuccessful, exiting..." 1
;;
2)
exitmsg "Error: There was a trouble when result check after osinfo detecting, exiting..." 2
;;
*)
exitmsg "Error: cd $2 unknown error " $?
;;
esac
}

@ -0,0 +1,5 @@
https://rsync.inferitos.ru/msvsphere/9.3/isos/x86_64/MSVSphere-9.3-x86_64-dvd.iso
https://rsync.inferitos.ru/msvsphere/9.3/isos/x86_64/MSVSphere-9.3-x86_64-netinstall.iso
https://rsync.inferitos.ru/msvsphere/9.3/isos/x86_64/MSVSphere-9.3-x86_64-minimal.iso
https://rsync.inferitos.ru/msvsphere/9.3/isos/x86_64/MSVSphere-9.3-x86_64-server.iso
https://rsync.inferitos.ru/msvsphere/9.3/isos/x86_64/MSVSphere-9.3-x86_64-arm.iso

@ -0,0 +1,2 @@
Media is bootable.
Media is an installer for OS 'MSVSphere 9 (x86_64)'

@ -0,0 +1,153 @@
#!/bin/bash
#----------------------------------------------------------------------
# Description: osinfo-detect-test.sh - Check msvsphere patches are working for osinfo-db
# Author: td25i <a.lyubimov@softline.com>
# Created at: Mon Dec 4 10:53:18 MSK 2023
# Computer: ii7
# System: Linux 5.14.0-362.8.1.el9_3.x86_64 on x86_64
#
# Copyright (c) 2023 Softline All rights reserved.
#
#----------------------------------------------------------------------
# Configure section:
# v0.1
dnf -y in curl util-linux gawk which libosinfo coreutils diffutils
# TODO check exit stats
FUNCTIONS_FILE=./functions
DOWNLOAD_LIST_FILENAME=msvsphereiso.uri
TEST_REFERENCE_RESULT_FILE=osinfo-detect-reference.result
TEST_OBTAINED_RESULT_FILE=osinfo-detect-obtained.result
echo "Getting meminfo..."
MEMFREEKB=`grep MemFree /proc/meminfo | sed 's/ kB//g' | sed 's/ //g' | cut -f 2 -d :`
echo "Getting free space in /var/tmp ..."
DISTFREEKB=`df --output=avail /var/tmp | tail -n 1`
echo "Calculating sum sizes of ISO files..."
MEMFREEREQBYTES=$(curl -s https://rsync.inferitos.ru/msvsphere/9/isos/x86_64/ grep href\=\"MSVSphere | rev | cut -f 1 -d \ | awk '{s+=$1}END{print s}')
MEMFREEREQKB=`echo "scale=0; $MEMFREEREQBYTES/1024" | bc`
echo "Need $MEMFREEREQKB kB."
echo "Checking free space for download ISO images..."
echo "Choosing a location to place files.."
if [[ $MEMFREEKB -lt $MEMFREEREQKB ]]
then
echo "With less RAM $MEMFREEKB kB, use /var/tmp"
WORK_DIR=`mktemp -d --suffix=.osinfo-db-tests -p /var/tmp`
else
echo "RAM is enough $MEMFREEKB kB, use /tmp"
WORK_DIR=`mktemp -d --suffix=.osinfo-db-tests`
fi
declare -a REF_TESTING_RESULTS=()
declare -a TESTING_RESULTS=()
cleantempdata()
{
rm -rv $1
}
# TODO
cp $DOWNLOAD_LIST_FILENAME $TEST_REFERENCE_RESULT_FILE $WORK_DIR/
if [[ -f $FUNCTIONS_FILE ]]
then
. $FUNCTIONS_FILE
else
echo "Error: file $FUNCTIONS_FILE not found, exiting..."
exit 1
fi
which basename || exitmsg "Error: basename not found, exiting..." $?
which sha256sum || exitmsg "Error: sha256sum not found, exiting..." $?
cd $WORK_DIR
cdcheck $? $REF_GIT_DIR
wgetdownload()
{
while read LINE; do
wget -c $LINE
wgetcheck $? $LINE
wget -c $LINE.CHECKSUM
wgetcheck $? $LINE.CHECKSUM
done < $1
}
if [[ -f $DOWNLOAD_LIST_FILENAME ]]
then
wgetdownload $DOWNLOAD_LIST_FILENAME
else
#cleantempdata $WORK_DIR
exitmsg "Error: file $DOWNLOAD_LIST_FILENAME not found, exiting..." 1
fi
if [[ ! -f $TEST_REFERENCE_RESULT_FILE ]]
then
cleantempdata $WORK_DIR
exitmsg "Error: file $TEST_REFERENCE_RESULT_FILE not found, exiting..." 1
fi
while read LINE; do
ITEM=`basename $LINE`
REF_TESTING_RESULTS+=("$ITEM")
done < $WORK_DIR/$DOWNLOAD_LIST_FILENAME
integrityverify()
{
while read LINE; do
ITEM=`basename $LINE`
sha256sum -c --ignore-missing $ITEM.CHECKSUM
if [[ ! $? == 0 ]]
then
cleantempdata $WORK_DIR
exitmsg "osinfo-detect-test.sh log: sha256sum failed for $ITEM, exiting..." $?
fi
echo "Verifying sha256sum of $ITEM successully completed."
done < $WORK_DIR/$DOWNLOAD_LIST_FILENAME
}
integrityverify
osinfodetect()
{
while read LINE; do
ITEM=`basename $LINE`
osinfo-detect $ITEM | tee $TEST_OBTAINED_RESULT_FILE
if [[ $? == 0 ]]
then
echo "Detecting of $ITEM completed without errors, starting comparing detected result with right value..."
diff -qsa $TEST_REFERENCE_RESULT_FILE $TEST_OBTAINED_RESULT_FILE
if [[ ! $? == 0 ]]
then
cleantempdata $WORK_DIR
exitmsg "Error: Testing osinfo-detect failed for $ITEM, exiting..." 1
else
echo "Testing osinfo-detect with "$ITEM" are successful."
TESTING_RESULTS+=("$ITEM")
fi
else
cleantempdata $WORK_DIR
exitmsg "osinfo-detect-test.sh log: osinfo-detect failed for $ITEM, exiting..." $?
fi
done < $WORK_DIR/$DOWNLOAD_LIST_FILENAME
}
osinfodetect
for I in "${REF_TESTING_RESULTS[@]}"
do
echo "Referenced item $I"
done
for I in "${TESTING_RESULTS[@]}"
do
echo "Tested item $I"
done
cleantempdata $WORK_DIR
Loading…
Cancel
Save