Index: tests/sys/ses/destructive.c =================================================================== --- tests/sys/ses/destructive.c +++ tests/sys/ses/destructive.c @@ -66,7 +66,9 @@ globfree(&g); } -static bool do_setelmstat(const char *devname __unused, int fd) { +static bool +do_setelmstat(const char *devname __unused, int fd) +{ encioc_element_t *map; unsigned elm_idx; unsigned nobj; @@ -84,7 +86,6 @@ for (elm_idx = 0; elm_idx < nobj; elm_idx++) { encioc_elm_status_t elmstat; struct ses_ctrl_dev_slot *cslot; - struct ses_status_dev_slot *sslot; if (last_elm_type != map[elm_idx].elm_type) { /* skip overall elements */ @@ -97,9 +98,10 @@ { r = ioctl(fd, ENCIOC_GETELMSTAT, (caddr_t)&elmstat); ATF_REQUIRE_EQ(r, 0); + ses_status_to_ctrl(map[elm_idx].elm_type, + &elmstat.cstat[0]); cslot = (struct ses_ctrl_dev_slot*)&elmstat.cstat[0]; - sslot = (struct ses_status_dev_slot*)&elmstat.cstat[0]; ses_ctrl_common_set_select(&cslot->common, 1); ses_ctrl_dev_slot_set_rqst_ident(cslot, 1); @@ -112,7 +114,8 @@ last_elm_type = -1; for (elm_idx = 0; elm_idx < nobj; elm_idx++) { encioc_elm_status_t elmstat; - struct ses_status_dev_slot *sslot; + struct ses_status_dev_slot *sslot = + (struct ses_status_dev_slot*)&elmstat.cstat[0]; if (last_elm_type != map[elm_idx].elm_type) { /* skip overall elements */ @@ -125,11 +128,6 @@ { int i; - r = ioctl(fd, ENCIOC_GETELMSTAT, (caddr_t)&elmstat); - ATF_REQUIRE_EQ(r, 0); - - sslot = (struct ses_status_dev_slot*)&elmstat.cstat[0]; - for (i = 0; i < 10; i++) { r = ioctl(fd, ENCIOC_GETELMSTAT, (caddr_t)&elmstat); @@ -155,7 +153,8 @@ * Instead, we'll just clear every ident bit. */ static bool -do_setelmstat_cleanup(const char *devname __unused, int fd __unused) { +do_setelmstat_cleanup(const char *devname __unused, int fd __unused) +{ encioc_element_t *map; unsigned elm_idx; unsigned nobj; @@ -168,6 +167,7 @@ map = calloc(nobj, sizeof(encioc_element_t)); ATF_REQUIRE(map != NULL); r = ioctl(fd, ENCIOC_GETELMMAP, (caddr_t) map); + ATF_REQUIRE_EQ(r, 0); /* Clear the IDENT bit for every disk slot */ for (elm_idx = 0; elm_idx < nobj; elm_idx++) { @@ -183,11 +183,15 @@ if (map[elm_idx].elm_type == ELMTYP_DEVICE || map[elm_idx].elm_type == ELMTYP_ARRAY_DEV) { + r = ioctl(fd, ENCIOC_GETELMSTAT, (caddr_t)&elmstat); + ATF_REQUIRE_EQ(r, 0); + cslot = (struct ses_ctrl_dev_slot*)&elmstat.cstat[0]; ses_ctrl_common_set_select(&cslot->common, 1); ses_ctrl_dev_slot_set_rqst_ident(cslot, 0); r = ioctl(fd, ENCIOC_SETELMSTAT, (caddr_t)&elmstat); + ATF_REQUIRE_EQ(r, 0); } } @@ -211,7 +215,9 @@ } -static bool do_setencstat(const char *devname __unused, int fd) { +static bool +do_setencstat(const char *devname __unused, int fd) +{ unsigned char encstat; int r, i; bool worked = false; @@ -241,7 +247,9 @@ return (true); } -static bool do_setencstat_cleanup(const char *devname __unused, int fd) { +static bool +do_setencstat_cleanup(const char *devname __unused, int fd) +{ unsigned char encstat; /* @@ -283,7 +291,6 @@ */ ATF_TP_ADD_TC(tp, setelmstat); ATF_TP_ADD_TC(tp, setencstat); - // TODO ENCIOC_SETELMSTAT return (atf_no_error()); } Index: tests/sys/ses/nondestructive.c =================================================================== --- tests/sys/ses/nondestructive.c +++ tests/sys/ses/nondestructive.c @@ -42,7 +42,9 @@ #include "common.h" -static bool do_getelmdesc(const char *devname, int fd) { +static bool +do_getelmdesc(const char *devname, int fd) +{ regex_t re; FILE *pipe; char cmd[256]; @@ -123,11 +125,13 @@ for_each_ses_dev(do_getelmdesc, O_RDONLY); } -static bool do_getelmdevnames(const char *devname __unused, int fd) { +static bool +do_getelmdevnames(const char *devname __unused, int fd) +{ encioc_element_t *map; unsigned nobj; const size_t namesize = 128; - int r; + int r, status; char *namebuf; unsigned elm_idx; @@ -162,8 +166,10 @@ elmdn.elm_devnames = namebuf; namebuf[0] = '\0'; r = ioctl(fd, ENCIOC_GETELMDEVNAMES, (caddr_t) &elmdn); - if (e_status.cstat[0] != SES_OBJSTAT_UNSUPPORTED && - e_status.cstat[0] != SES_OBJSTAT_NOTINSTALLED && + status = ses_status_common_get_element_status_code( + (struct ses_status_common*)&e_status.cstat[0]); + if (status != SES_OBJSTAT_UNSUPPORTED && + status != SES_OBJSTAT_NOTINSTALLED && (map[elm_idx].elm_type == ELMTYP_DEVICE || map[elm_idx].elm_type == ELMTYP_ARRAY_DEV)) { @@ -174,8 +180,7 @@ if (r == 0) { size_t z = 0; - int da = 0, ada = 0, pass = 0, nvd = 0; - int nvme = 0, unknown = 0; + int da = 0, ada = 0, pass = 0, nda = 0, unknown = 0; while(elmdn.elm_devnames[z] != '\0') { size_t e; @@ -191,16 +196,14 @@ ada++; else if (0 == strncmp("pass", s, e)) pass++; - else if (0 == strncmp("nvd", s, e)) - nvd++; - else if (0 == strncmp("nvme", s, e)) - nvme++; + else if (0 == strncmp("nda", s, e)) + nda++; else unknown++; z += strcspn(elmdn.elm_devnames + z, ","); } /* There should be one pass dev for each non-pass dev */ - ATF_CHECK_EQ(pass, da + ada + nvd + nvme); + ATF_CHECK_EQ(pass, da + ada + nda); ATF_CHECK_EQ_MSG(0, unknown, "Unknown device names %s", elmdn.elm_devnames); } @@ -225,7 +228,8 @@ } static int -elm_type_name2int(const char *name) { +elm_type_name2int(const char *name) +{ const char *elm_type_names[] = ELM_TYPE_NAMES; int i; @@ -237,7 +241,9 @@ return (-1); } -static bool do_getelmmap(const char *devname, int fd) { +static bool +do_getelmmap(const char *devname, int fd) +{ encioc_element_t *map; FILE *pipe; char cmd[256]; @@ -314,7 +320,9 @@ for_each_ses_dev(do_getelmmap, O_RDONLY); } -static bool do_getelmstat(const char *devname, int fd) { +static bool +do_getelmstat(const char *devname, int fd) +{ encioc_element_t *map; unsigned elm_idx; unsigned nobj; @@ -383,7 +391,9 @@ for_each_ses_dev(do_getelmstat, O_RDONLY); } -static bool do_getencid(const char *devname, int fd) { +static bool +do_getencid(const char *devname, int fd) +{ encioc_string_t stri; FILE *pipe; char cmd[256]; @@ -431,7 +441,9 @@ for_each_ses_dev(do_getencid, O_RDONLY); } -static bool do_getencname(const char *devname, int fd) { +static bool +do_getencname(const char *devname, int fd) +{ encioc_string_t stri; FILE *pipe; char cmd[256]; @@ -475,7 +487,9 @@ for_each_ses_dev(do_getencname, O_RDONLY); } -static bool do_getencstat(const char *devname, int fd) { +static bool +do_getencstat(const char *devname, int fd) +{ FILE *pipe; char cmd[256]; unsigned char e, estat, invop, info, noncrit, crit, unrecov; @@ -516,7 +530,9 @@ for_each_ses_dev(do_getencstat, O_RDONLY); } -static bool do_getnelm(const char *devname, int fd) { +static bool +do_getnelm(const char *devname, int fd) +{ FILE *pipe; char cmd[256]; char line[256]; @@ -562,7 +578,9 @@ for_each_ses_dev(do_getnelm, O_RDONLY); } -static bool do_getstring(const char *devname, int fd) { +static bool +do_getstring(const char *devname, int fd) +{ FILE *pipe; char cmd[256]; char *sg_ses_buf, *ses_buf;