]> gitweb.morketsmerke.org Git - immudex-testing.git/commitdiff
Poprawiono większośc błędów w testach
authorxf0r3m <jakubstasinski@protonmail.com>
Thu, 3 Aug 2023 12:23:05 +0000 (14:23 +0200)
committerxf0r3m <jakubstasinski@protonmail.com>
Thu, 3 Aug 2023 12:23:05 +0000 (14:23 +0200)
tests.sh

index 591781865306d6294c6cf5b2f679960a7030d765..49af46417bd0d20c627a6af3f2cebe0aaf0aa44c 100755 (executable)
--- a/tests.sh
+++ b/tests.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 function is_in_file() {
-  grep -q "^${1}$" $2;
+  grep -q "^${1}$" $2 2>/dev/null;
   return $?;
 }
 
@@ -16,35 +16,35 @@ function is_running() {
 }
 
 function is_package_installed() {
-  apt list --installed | grep -q $1;
+  apt list --installed 2>/dev/null | grep -q $1;
   return $?
 }
 
 function is_immudex_lightdm_wallpaper() {
   value='background = /usr/share/images/desktop-base/lightdm_wallpaper.jpg';
   file="/etc/lightdm/lightdm-gtk-greeter.conf";
-  result=$(is_in_file $value $file);
+  result=$(grep -q "^${value}$" $file);
   return $result;
 }
 
 function is_immudex_lightdm_default_user_image() {
   value='default-user-image = /usr/share/images/desktop-base/immudex_xfce_greeter_logo.png';
   file="/etc/lightdm/lightdm-gtk-greeter.conf";
-  result=$(is_in_file $value $file);
+  result=$(grep -q "^${value}$" $file);
   return $result;
 }
 
 function is_immudex_lightdm_theme() {
   value='theme-name = Adwaita-dark';
   file="/etc/lightdm/lightdm-gtk-greeter.conf";
-  result=$(is_in_file $value $file);
+  result=$(grep -q "^${value}$" $file);
   return $result;
 }
 
 function is_immudex_default_wallpaper_set() {
   value="/usr/share/images/desktop-base/d13_wallpaper.png";
   file="/usr/share/images/desktop-base/default";
-  if [ -L $file ] && grep -q "${value}$"; then
+  if [ -L $file ] && $(file $file | grep -q "${value}$"); then
     return 0;
   else
     return 1;
@@ -52,7 +52,7 @@ function is_immudex_default_wallpaper_set() {
 }
 
 function is_immudex_panel_whiskermenu_ok() {
-  value="~/immudex-testing/files/104/whiskermenu-1.rc";
+  value="$HOME/immudex-testing/files/104/whiskermenu-1.rc";
   file="/home/user/.config/xfce4/panel/whiskermenu-1.rc";
   result=$(is_file_correct $value $file);
   return $result;
@@ -62,7 +62,7 @@ function is_immudex_panel_activator_1_ok() {
   value='Name=Firefox ESR (Firejailed)';
   value1="Exec=/usr/local/bin/secured-firefox";
   file="/home/user/.config/xfce4/panel/launcher-5/16844254192.desktop";
-  result=$($(is_in_file $value $file) && $(is_in_file $value1 $file));
+  result=$($(grep -q "^${value}$" $file 2> /dev/null) && $(is_in_file $value1 $file));
   return $result;
 }
 
@@ -70,7 +70,7 @@ function is_immudex_panel_activator_2_ok() {
   value="Exec=xfce4-terminal";
   value1='Name=Terminal Emulator';
   file="/home/user/.config/xfce4/panel/launcher-7/16844254905.desktop"
-  result=$($(is_in_file $value $file) && $(is_in_file $value1 $file));
+  result=$($(is_in_file $value $file) && $(grep -q "^${value}$" $file 2>/dev/null));
   return $result;
 }
 
@@ -78,19 +78,19 @@ function is_immudex_panel_activatior_3_ok() {
   value="Name=Padlock";
   value1='Exec=xfce4-terminal -x /usr/local/bin/padlock';
   file="/home/user/.config/xfce4/panel/launcher-14/16844255236.desktop";
-  result=$($(is_in_file $value $file) && $(is_in_file $value1 $file));
+  result=$($(is_in_file $value $file) && $(grep -q "^${value1}$" $file 2>/dev/null));
   return $result;
 }
 
 function is_immudex_widget_connky_running() {
   value='conky --daemonize --pause=5';
   value1="$USER";
-  result=$(is_running $value $value1);
+  result=$(ps -aux | grep "$value" | head -1 | grep -q $value1);
   return $result;
 }
 
 function is_immudex_conky_file_ok() {
-  wget https://github.com/xf0r3m/xfcedebian/raw/d13/conkyrc -O /tmp/d13_conkyrc;
+  wget -q https://github.com/xf0r3m/xfcedebian/raw/d13/conkyrc -O /tmp/d13_conkyrc;
   value="/tmp/d13_conkyrc";
   value1="/home/user/.conkyrc";
   result=$(is_file_correct $value $value1);
@@ -98,7 +98,7 @@ function is_immudex_conky_file_ok() {
 }
 
 function is_immudex_keyboard_shortcut_config_ok() {
-  value="~/immudex-testing/files/104/xfce4-keyboard-shortcuts.xml";
+  value="$HOME/immudex-testing/files/104/xfce4-keyboard-shortcuts.xml";
   value1="/home/user/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml";
   result=$(is_file_correct $value $value1);
   return $result;
@@ -122,68 +122,68 @@ function is_immudex_check_terminal_config() {
 }
 
 function is_immudex_xfce_notes_config() {
-  value="~/immudex-testing/files/100/gtk-main.css";
+  value="$HOME/immudex-testing/files/100/gtk-main.css";
   value1="/usr/share/xfce4-notes-plugin/gtk-3.0/gtk-main.css";
   result=$(is_file_correct $value $value1);
        return $result;
 }
 
 function is_immudex_irssi_config_file_ok() {
-  value="~/immudex-testing/files/100/config";
+  value="$HOME/immudex-testing/files/100/config";
   value1="/home/user/.irssi/config";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_irssi_default_theme_ok() {
-  value="~/immudex-testing/files/100/default.theme";
+  value="$HOME/immudex-testing/files/100/default.theme";
   value1="/home/user/.irssi/default.theme";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_libreoffice_config_dir() {
-  [-d /home/user/.config/libreoffice ];
+  [ -d /home/user/.config/libreoffice ];
   return $?;
 }
 
 function is_immudex_firejail_config_ok() {
-  value="~/immudex-testing/files/100/firejail.config";
+  value="$HOME/immudex-testing/files/100/firejail.config";
   value1="/etc/firejail/firejail.config";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_notifier_distro_autostart_file_ok() {
-  value='~/immudex-testing/files/100/Notifier - distro.desktop';
-  value1='/home/user/.config/autostart/Notifier - distro.desktop';
-  result=$(is_file_correct $value $value1);
+  value="$HOME/immudex-testing/files/100/Notifier\ \-\ distro.desktop";
+  value1="/home/user/.config/autostart/Notifier\ \-\ distro.desktop";
+  result=$(eval "cmp $value $value1 > /dev/null 2>&1");
   return $result;
 }
 
 function is_immudex_notifier_packages_autostart_file_ok() {
-  value='~/immudex-testing/files/Notifier - packages.desktop';
-  value1='/home/xf0r3m/.config/autostart/Notifier - packages.desktop';
-  result=$(is_file_correct $value $value1);
+  value="$HOME/immudex-testing/files/Notifier\ \-\ packages.desktop";
+  value1="/home/xf0r3m/.config/autostart/Notifier\ \-\ packages.desktop";
+  result=$(eval "cmp $value $value1 > /dev/null 2>&1");
   return $result;
 }
 
 function is_immudex_redshift_config_ok() {
-  value="~/immudex-testing/files/100/redshift.conf";
+  value="$HOME/immudex-testing/files/100/redshift.conf";
   value1="/etc/skel/.config/redshift.conf";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_redshift_autostart_file_ok() {
-  value="~/immudex-testing/files/100/redshift.desktop";
+  value="$HOME/immudex-testing/files/100/redshift.desktop";
   value1="/etc/skel/.config/autostart/redshift.desktop";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_user_defined_mime_ok() {
-  value="~/immudex-testing/files/100/mimeapps.list";
+  value="$HOME/immudex-testing/files/100/mimeapps.list";
   value1="/etc/skel/.config/mimeapps.list";
   result=$(is_file_correct $value $value1);
   return $result;
@@ -195,8 +195,8 @@ function is_immudex_sync_sh_share_dir() {
 }
 
 function is_immudex_hostname_service_file_ok() {
-  value="~/immudex-tesitng/files/100/immudex_hostname.service";
-  value1="/etc/systemd/system";
+  value="$HOME/immudex-testing/files/100/immudex_hostname.service";
+  value1="/etc/systemd/system/immudex_hostname.service";
   result=$(is_file_correct $value $value1);
   return $result;
 }
@@ -204,26 +204,26 @@ function is_immudex_hostname_service_file_ok() {
 function is_immudex_right_firefox_profile() {
   value='user_pref("extensions.lastPlatformVersion", "115.0.2");';
   file="/home/user/.mozilla/firefox/l9vw01ma.default-esr/prefs.js";
-  result=$(is_in_file $value $file);
+  result=$(grep -q "^${value}$" $file 2> /dev/null);
   return $result;
 }
 
 function is_immudex_apply_image_ok() {
-  value="~/immudex-testing/images/100/apply.png";
+  value="$HOME/immudex-testing/images/100/apply.png";
   value1="/usr/share/icons/apply.png";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_rss_image_ok() {
-  value="~/immudex-testing/images/100/rss.png";
+  value="$HOME/immudex-testing/images/100/rss.png";
   value1="/usr/share/icons/rss.png";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_notes_background_image_ok() {
-  value="~/immudex-testing/images/100/notes-background.jpg";
+  value="$HOME/immudex-testing/images/100/notes-background.jpg";
   value1="/usr/share/images/desktop-base/notes-background.jpg";
   result=$(is_file_correct $value $value1);
   return $result;
@@ -247,9 +247,9 @@ function is_immudex_motd2_enabled() {
 }
 
 function is_immudex_chhome_alias() {
-  value="^alias chhome";
+  value="alias chhome";
   file="/etc/bash.bashrc";
-  result=$(is_in_file $value $file);
+  result=$(grep -q "^${value}" $file 2>/dev/null);
   return $result;
 }
 
@@ -268,21 +268,21 @@ function is_immudex_is_default_hostname() {
 function is_immudex_has_resolv_in_etc_hosts() {
   value='127.0.1.1  immudex';
   file="/etc/hosts";
-  result=$(is_in_file $value $file);
+  result=$(grep -q "^${value}$" $file 2>/dev/null);
   return $result;
 }
 
 function is_immudex_user_is_in_sudoers_file() {
   value='user ALL=(ALL:ALL) NOPASSWD:ALL';
   file="/etc/sudoers";
-  result=$(is_in_file $value $file);
+  result=$(sudo grep -q "^${value}$" $file 2>/dev/null);
   return $result;
 }
 
 function is_immudex_xf0r3m_is_in_sudoers_file() {
-  value='^xf0r3m ALL=(ALL:ALL) NOPASSWD:ALL';
+  value='xf0r3m ALL=(ALL:ALL) NOPASSWD:ALL';
   file="/etc/sudoers";
-  result=$(is_in_file $value $file);
+  result=$(sudo grep -q "^${value}$" $file 2>/dev/null);
   return $result;
 }
 
@@ -319,161 +319,161 @@ function is_immudex_user_dot_vimrc_file() {
 }
 
 function is_immudex_xfce4_notes_autostart() {
-  value="~/immudex-testing/files/autostart-x4notes.desktop";
+  value="$HOME/immudex-testing/files/autostart-x4notes.desktop";
   value1="/home/xf0r3m/.config/autostart/autostart-x4notes.desktop";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_create_media_ok() {
-  value="~/immudex-testing/files/106/create_media";
+  value="$HOME/immudex-testing/tools/106/create_media";
   value1="/usr/local/bin/create_media";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_immudex_hostname_ok() {
-  value="~/immudex-testing/files/106/immudex_hostname";
+  value="$HOME/immudex-testing/tools/106/immudex_hostname";
   value1="/usr/local/bin/immudex_hostname";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_pl_ok() { 
-  value="~/immudex-testing/files/105/pl";
+  value="$HOME/immudex-testing/tools/105/pl";
   value1="/usr/local/bin/pl";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_newsfeed_ok() {
-  value="~/immudex-testing/files/103/newsfeed";
+  value="$HOME/immudex-testing/tools/103/newsfeed";
   value1="/usr/local/bin/newsfeed";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_immudex_addons_ok() {
-  value="~/immudex-testing/files/101/immudex_addons";
+  value="$HOME/immudex-testing/tools/101/immudex_addons";
   value1="/usr/local/bin/immudex_addons";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_autostart-x4notes_ok() {
-  value="~/immudex-testing/files/100/autostart-x4notes_ok";
+  value="$HOME/immudex-testing/tools/100/autostart-x4notes";
   value1="/usr/local/bin/autostart-x4notes";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_immudex_branch_ok() {
-  value="~/immudex-testing/files/100/immudex_branch";
+  value="$HOME/immudex-testing/tools/100/immudex_branch";
   value1="/usr/local/bin/immudex_branch";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_immudex_crypt_ok() {
-  value="~/immudex-testing/files/100/immudex_crypt";
+  value="$HOME/immudex-testing/tools/100/immudex_crypt";
   value1="/usr/local/bin/immudex_crypt";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_immudex_install_ok() {
-  value="~/immudex-testing/files/100/immudex_install";
+  value="$HOME/immudex-testing/tools/100/immudex_install";
   value1="/usr/local/bin/immudex_install";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_immudex_upgrade_ok() {
-  value="~/immudex-testing/files/100/immudex_upgrade";
+  value="$HOME/immudex-testing/tools/100/immudex_upgrade";
   value1="/usr/local/bin/immudex_upgrade";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_import_gpgkeys_ok() {
-  value="~/immudex-testing/files/100/import_gpgkeys";
+  value="$HOME/immudex-testing/tools/100/import_gpgkeys";
   value1="/usr/local/bin/import_gpgkeys";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_import_sshkeys_ok() {
-  value="~/immudex-testing/files/100/import_sshkeys";
+  value="$HOME/immudex-testing/tools/100/import_sshkeys";
   value1="/usr/local/bin/import_sshkeys";
   result=$(is_file_correct $value $value1);
        return $result;
 }
 
 function is_immudex_tool_library_ok() {
-  value="~/immudex-testing/files/100/library.sh";
+  value="$HOME/immudex-testing/tools/100/library.sh";
   value1="/usr/local/bin/library.sh";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_meteo_ok() {
-  value="~/immudex-testing/files/100/meteo";
+  value="$HOME/immudex-testing/tools/100/meteo";
   value1="/usr/local/bin/meteo";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_morketsmerke_ok() {
-  value="~/immudex-testing/files/100/morketsmerke";
+  value="$HOME/immudex-testing/tools/100/morketsmerke";
   value1="/usr/local/bin/morketsmerke";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_motd2_ok() {
-  value="~/immudex-testing/files/100/motd2";
+  value="$HOME/immudex-testing/tools/100/motd2";
   value1="/usr/local/bin/motd2";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_notifier_ok() {
-  value="~/immudex-testing/files/100/notifier";
+  value="$HOME/immudex-testing/tools/100/notifier";
   value1="/usr/local/bin/notifier";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_padlock_ok() {
-  value="~/immudex-testing/files/100/padlock";
+  value="$HOME/immudex-testing/tools/100/padlock";
   value1="/usr/local/bin/padlock";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_secured-firefox_ok() {
-  value="~/immudex-testing/files/100/secured-firefox";
+  value="$HOME/immudex-testing/tools/100/secured-firefox";
   value1="/usr/local/bin/secured-firefox";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_shoutcasts_ok() {
-  value="~/immudex-testing/files/100/shoutcasts";
+  value="$HOME/immudex-testing/tools/100/shoutcasts";
   value1="/usr/local/bin/shoutcasts";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_sync_ok() {
-  value="~/immudex-tesitng/files/100/sync.sh";
+  value="$HOME/immudex-testing/tools/100/sync.sh";
   value1="/usr/local/bin/sync.sh";
   result=$(is_file_correct $value $value1);
   return $result;
 }
 
 function is_immudex_tool_ytplay_ok() {
-  value="~/immudex-testing/files/100/ytplay";
+  value="$HOME/immudex-testing/tools/100/ytplay";
   value1="/usr/local/bin/ytplay";
   result=$(is_file_correct $value $value1);
   return $result;
@@ -494,7 +494,7 @@ function check_packages() {
 }
 
 
-flist="is_immudex_lightdm_wallpaper is_immudex_lightdm_default_user_image is_immudex_lightdm_theme is_immudex_default_wallpaper_set is_immudex_panel_whiskermenu_ok is_immudex_panel_activator_1_ok is_immudex_panel_activator_2_ok is_immudex_panel_activatior_3_ok is_immudex_widget_connky_running is_immudex_conky_file_ok is_immudex_keyboard_shortcut_config_ok is_immudex_check_terminal_config is_immudex_xfce_notes_config is_immudex_irssi_config_file_ok is_immudex_irssi_default_theme_ok is_immudex_libreoffice_config_dir is_immudex_firejail_config_ok is_immudex_notifier_distro_autostart_file_ok is_immudex_notifier_packages_autostart_file_ok is_immudex_redshift_config_ok is_immudex_redshift_autostart_file_ok is_immudex_user_defined_mime_ok is_immudex_sync_sh_share_dir is_immudex_hostname_service_file_ok is_immudex_right_firefox_profile is_immudex_apply_image_ok is_immudex_rss_image_ok is_immudex_notes_background_image_ok isnt_immudex_notrespass_backgroung_file is_immudex_hostname_service_enabled is_immudex_motd2_enabled is_immudex_chhome_alias is_immudex_ping_command_has_setuid is_immudex_is_default_hostname is_immudex_has_resolv_in_etc_hosts is_immudex_user_is_in_sudoers_file is_immudex_xf0r3m_is_in_sudoers_file is_immudex_dot_bashrc_user_file is_immudex_user_profile_image is_immudex_user_profile_image_icon is_immudex_user_fonts_dir is_immudex_user_dot_profile_file is_immudex_user_dot_vimrc_file is_immudex_xfce4_notes_autostart is_immudex_tool_create_media_ok is_immudex_tool_immudex_hostname_ok is_immudex_tool_pl_ok is_immudex_tool_newsfeed_ok is_immudex_tool_immudex_addons_ok is_immudex_tool_autostart-x4notes_ok is_immudex_tool_immudex_branch_ok is_immudex_tool_immudex_crypt_ok is_immudex_tool_immudex_install_ok is_immudex_tool_immudex_upgrade_ok is_immudex_tool_import_gpgkeys_ok is_immudex_tool_import_sshkeys_ok is_immudex_tool_library_ok is_immudex_tool_meteo_ok is_immudex_tool_morketsmerke_ok is_immudex_tool_motd2_ok is_immudex_tool_notifier_ok is_immudex_tool_padlock_ok is_immudex_tool_secured-firefox_ok is_immudex_tool_shoutcasts_ok is_immudex_tool_sync_ok is_immudex_tool_ytplay_ok";
+flist="is_immudex_lightdm_wallpaper is_immudex_lightdm_default_user_image is_immudex_lightdm_theme is_immudex_default_wallpaper_set is_immudex_panel_whiskermenu_ok is_immudex_panel_activator_1_ok is_immudex_panel_activator_2_ok is_immudex_panel_activatior_3_ok is_immudex_widget_connky_running is_immudex_conky_file_ok is_immudex_keyboard_shortcut_config_ok is_immudex_check_terminal_config is_immudex_xfce_notes_config is_immudex_irssi_config_file_ok is_immudex_irssi_default_theme_ok is_immudex_libreoffice_config_dir is_immudex_firejail_config_ok is_immudex_notifier_distro_autostart_file_ok is_immudex_notifier_packages_autostart_file_ok is_immudex_redshift_config_ok is_immudex_redshift_autostart_file_ok is_immudex_user_defined_mime_ok is_immudex_sync_sh_share_dir is_immudex_hostname_service_file_ok is_immudex_right_firefox_profile is_immudex_apply_image_ok is_immudex_rss_image_ok is_immudex_notes_background_image_ok isnt_immudex_notrespass_backgroung_file is_immudex_hostname_service_enabled is_immudex_motd2_enabled is_immudex_chhome_alias is_immudex_ping_command_has_setuid is_immudex_user_is_in_sudoers_file is_immudex_xf0r3m_is_in_sudoers_file is_immudex_dot_bashrc_user_file is_immudex_user_profile_image is_immudex_user_profile_image_icon is_immudex_user_fonts_dir is_immudex_user_dot_profile_file is_immudex_user_dot_vimrc_file is_immudex_xfce4_notes_autostart is_immudex_tool_create_media_ok is_immudex_tool_immudex_hostname_ok is_immudex_tool_pl_ok is_immudex_tool_newsfeed_ok is_immudex_tool_immudex_addons_ok is_immudex_tool_autostart-x4notes_ok is_immudex_tool_immudex_branch_ok is_immudex_tool_immudex_crypt_ok is_immudex_tool_immudex_install_ok is_immudex_tool_immudex_upgrade_ok is_immudex_tool_import_gpgkeys_ok is_immudex_tool_import_sshkeys_ok is_immudex_tool_library_ok is_immudex_tool_meteo_ok is_immudex_tool_morketsmerke_ok is_immudex_tool_motd2_ok is_immudex_tool_notifier_ok is_immudex_tool_padlock_ok is_immudex_tool_secured-firefox_ok is_immudex_tool_shoutcasts_ok is_immudex_tool_sync_ok is_immudex_tool_ytplay_ok";
 
 function tests() {
   for fn in $@; do