Skip to content

Commit

Permalink
tests/xbps/xbps-query: add tests for [--long] -f
Browse files Browse the repository at this point in the history
  • Loading branch information
classabbyamp committed Mar 16, 2023
1 parent 670da7b commit 799758c
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/xbps/xbps-query/list_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,43 @@ list_repos_body() {
atf_check_equal "$output" " -1 https://localhost/wtf (RSA maybe-signed)"
}

list_files_head() {
atf_set "descr" "xbps-query(1) [--long] -f"
}

list_files_body() {
mkdir -p some_repo pkg/bin
cd pkg/bin
touch suidfile
chmod 4755 suidfile
touch suidfile_no_x
chmod 4644 suidfile_no_x
touch sgidfile
chmod 2755 sgidfile
touch sgidfile_no_x
chmod 2644 sgidfile_no_x
touch some_exe
chmod 0750 some_exe
touch some_file
chmod 0644 some_file
touch owned_by_nobody
touch owned_by_foo
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAA" > file_with_size
ln -s foo symlink
cd ../../some_repo
xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" \
--chown "/bin/owned_by_nobody:nobody:root /bin/owned_by_foo:foo:foo" ../pkg
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
output="$(xbps-query -C empty.conf -i --repository=some_repo -f foo | tr -d '\n')"
atf_check_equal "$output" "/bin/file_with_size/bin/owned_by_foo/bin/owned_by_nobody/bin/sgidfile/bin/sgidfile_no_x/bin/some_exe/bin/some_file/bin/suidfile/bin/suidfile_no_x/bin/symlink -> /bin/foo"
output="$(xbps-query -C empty.conf -i --repository=some_repo --long -f foo | tr -d '\n')"
atf_check_equal "$output" "-rw-r--r-- root root 29 B /bin/file_with_size-rw-r--r-- foo foo 0 B /bin/owned_by_foo-rw-r--r-- nobody root 0 B /bin/owned_by_nobody-rwxr-sr-x root root 0 B /bin/sgidfile-rw-r--r-- root root 0 B /bin/sgidfile_no_x-rwxr-x--- root root 0 B /bin/some_exe-rw-r--r-- root root 0 B /bin/some_file-rwsr-xr-x root root 0 B /bin/suidfile-rwSr--r-- root root 0 B /bin/suidfile_no_xl--------- root root 0 B /bin/symlink -> /bin/foo"
}

atf_init_test_cases() {
atf_add_test_case list_repos
atf_add_test_case list_files
}

0 comments on commit 799758c

Please sign in to comment.