Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Dec 2017 16:22:02 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r326827 - stable/11/lib/libcam/tests
Message-ID:  <201712131622.vBDGM216052581@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Wed Dec 13 16:22:02 2017
New Revision: 326827
URL: https://svnweb.freebsd.org/changeset/base/326827

Log:
  MFC r326101:
  
  Add a test case for cam_get_device with sa(4) devices
  
  sa(4) has some unique behavior that is special-cased in cam_get_device. The
  existing tests don't provide coverage for this special case.
  
  Reviewed by:	ken
  Sponsored by:	Spectra Logic Corp
  Differential Revision:	https://reviews.freebsd.org/D13185

Modified:
  stable/11/lib/libcam/tests/libcam_test.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libcam/tests/libcam_test.c
==============================================================================
--- stable/11/lib/libcam/tests/libcam_test.c	Wed Dec 13 16:20:55 2017	(r326826)
+++ stable/11/lib/libcam/tests/libcam_test.c	Wed Dec 13 16:22:02 2017	(r326827)
@@ -129,6 +129,33 @@ ATF_TC_BODY(cam_get_device_positive_test, tc)
 	ATF_REQUIRE(parsed_unit == expected_unit);
 }
 
+/* 
+ * sa(4) uniquely creates nsa and esa device nodes for non-rewind operations
+ * and eject-on-close operations.  cam_get_device must special case these nodes
+ * to always return the base device.
+ */
+ATF_TC_WITHOUT_HEAD(cam_get_device_sa_test);
+ATF_TC_BODY(cam_get_device_sa_test, tc)
+{
+	char parsed_dev_name[DEV_IDLEN + 1];
+	int parsed_unit;
+
+	ATF_REQUIRE_MSG(cam_get_device("nsa99", parsed_dev_name,
+	    nitems(parsed_dev_name), &parsed_unit) == 0,
+	    "cam_get_device failed");
+	ATF_REQUIRE_STREQ(parsed_dev_name, "sa");
+	ATF_REQUIRE(parsed_unit == 99);
+
+	strcpy(parsed_dev_name, "");
+	parsed_unit = -1;
+
+	ATF_REQUIRE_MSG(cam_get_device("esa99", parsed_dev_name,
+	    nitems(parsed_dev_name), &parsed_unit) == 0,
+	    "cam_get_device failed");
+	ATF_REQUIRE_STREQ(parsed_dev_name, "sa");
+	ATF_REQUIRE(parsed_unit == 99);
+}
+
 ATF_TC(cam_open_device_negative_test_O_RDONLY);
 ATF_TC_HEAD(cam_open_device_negative_test_O_RDONLY, tc)
 {
@@ -282,6 +309,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, cam_get_device_negative_test_nul_path);
 	ATF_TP_ADD_TC(tp, cam_get_device_negative_test_root);
 	ATF_TP_ADD_TC(tp, cam_get_device_positive_test);
+	ATF_TP_ADD_TC(tp, cam_get_device_sa_test);
 	ATF_TP_ADD_TC(tp, cam_open_device_negative_test_O_RDONLY);
 	ATF_TP_ADD_TC(tp, cam_open_device_negative_test_nonexistent);
 	ATF_TP_ADD_TC(tp, cam_open_device_negative_test_unprivileged);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712131622.vBDGM216052581>