diff --git a/p11-kit/test-objects.sh b/p11-kit/test-objects.sh index 8d7e2039..28c5f1fe 100755 --- a/p11-kit/test-objects.sh +++ b/p11-kit/test-objects.sh @@ -258,5 +258,58 @@ EOF fi } +test_generate_keypair_nonexistent_token() { + cat > list.exp < err.exp < list.out 2> err.out; then + assert_fail "unable to run: p11-kit generate-keypair" + fi + + : ${DIFF=diff} + if ! ${DIFF} list.exp list.out > list.diff; then + sed 's/^/# /' list.diff + assert_fail "output contains wrong result" + fi + : ${ECHO=echo} + : ${TAIL=tail} + ${ECHO} "$(${TAIL} -n1 err.out)" > err.out + if ! ${DIFF} err.exp err.out > err.diff; then + sed 's/^/# /' err.diff + assert_fail "stderr contains wrong result" + fi +} + +test_delete_nonexistent_token() { + cat > err.exp < list.exp < list.out 2> err.out; then + assert_fail "unable to run: p11-kit delete-object" + fi + + : ${DIFF=diff} + if ! ${DIFF} list.exp list.out > list.diff; then + sed 's/^/# /' list.diff + assert_fail "output contains wrong result" + fi + : ${ECHO=echo} + : ${TAIL=tail} + ${ECHO} "$(${TAIL} -n1 err.out)" > err.out + if ! ${DIFF} err.exp err.out > err.diff; then + sed 's/^/# /' err.diff + assert_fail "stderr contains wrong result" + fi +} + run test_list_all test_list_with_type test_list_exact test_list_nonexistent \ - test_export_cert test_export_pubkey test_generate_keypair + test_export_cert test_export_pubkey test_generate_keypair test_generate_keypair_nonexistent_token \ + test_delete_nonexistent_token diff --git a/p11-kit/test-profiles.sh b/p11-kit/test-profiles.sh index 46f0cb69..b719deb4 100755 --- a/p11-kit/test-profiles.sh +++ b/p11-kit/test-profiles.sh @@ -33,4 +33,31 @@ EOF fi } -run test_list_profiles +test_add_profile_nonexistent_token() { + cat > list.exp < err.exp < list.out 2> err.out; then + assert_fail "unable to run: p11-kit add-profile" + fi + + : ${DIFF=diff} + if ! ${DIFF} list.exp list.out > list.diff; then + sed 's/^/# /' list.diff + assert_fail "output contains wrong results" + fi + : ${ECHO=echo} + : ${TAIL=tail} + ${ECHO} "$(${TAIL} -n1 err.out)" > err.out + if ! ${DIFF} err.exp err.out > err.diff; then + sed 's/^/# /' err.diff + assert_fail "stderr contains wrong result" + fi +} + +run test_list_profiles \ + test_add_profile_nonexistent_token