svn commit: r341274 - stable/12/tests/sys/kqueue/libkqueue
David Bright
dab at FreeBSD.org
Fri Nov 30 01:45:56 UTC 2018
Author: dab
Date: Fri Nov 30 01:45:54 2018
New Revision: 341274
URL: https://svnweb.freebsd.org/changeset/base/341274
Log:
MFC r341068:
Make whitespace more consistent in libkqueue tests.
After r337820, which "corrected" some spaces-instead-of-tab whitespace
issues in the libkqueue tests, jmg@ pointed out that these files were
originally space-based, not tab-spaced, and so the correction should
have been to get rid of the tabs that had been introduced in previous
changes, not the spaces. This change does that. This is a whitespace
only change; no functional change is intended.
Reported by: jmg@
Sponsored by: Dell EMC Isilon
Modified:
stable/12/tests/sys/kqueue/libkqueue/main.c
stable/12/tests/sys/kqueue/libkqueue/proc.c
stable/12/tests/sys/kqueue/libkqueue/signal.c
stable/12/tests/sys/kqueue/libkqueue/timer.c
stable/12/tests/sys/kqueue/libkqueue/user.c
stable/12/tests/sys/kqueue/libkqueue/vnode.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/tests/sys/kqueue/libkqueue/main.c
==============================================================================
--- stable/12/tests/sys/kqueue/libkqueue/main.c Fri Nov 30 00:47:36 2018 (r341273)
+++ stable/12/tests/sys/kqueue/libkqueue/main.c Fri Nov 30 01:45:54 2018 (r341274)
@@ -85,7 +85,7 @@ kevent_get(int kqfd)
struct kevent *kev;
if ((kev = calloc(1, sizeof(*kev))) == NULL)
- err(1, "out of memory");
+ err(1, "out of memory");
nfds = kevent(kqfd, NULL, 0, kev, 1, NULL);
if (nfds < 1)
@@ -103,7 +103,7 @@ kevent_get_timeout(int kqfd, int seconds)
struct timespec timeout = {seconds, 0};
if ((kev = calloc(1, sizeof(*kev))) == NULL)
- err(1, "out of memory");
+ err(1, "out of memory");
nfds = kevent(kqfd, NULL, 0, kev, 1, &timeout);
if (nfds < 0) {
@@ -123,10 +123,10 @@ kevent_fflags_dump(struct kevent *kev)
#define KEVFFL_DUMP(attrib) \
if (kev->fflags & attrib) \
- strncat(buf, #attrib" ", 64);
+ strncat(buf, #attrib" ", 64);
if ((buf = calloc(1, 1024)) == NULL)
- abort();
+ abort();
/* Not every filter has meaningful fflags */
if (kev->filter == EVFILT_PROC) {
@@ -160,7 +160,7 @@ kevent_fflags_dump(struct kevent *kev)
#endif
buf[strlen(buf) - 1] = ')';
} else {
- snprintf(buf, 1024, "fflags = %x", kev->fflags);
+ snprintf(buf, 1024, "fflags = %x", kev->fflags);
}
return (buf);
@@ -173,10 +173,10 @@ kevent_flags_dump(struct kevent *kev)
#define KEVFL_DUMP(attrib) \
if (kev->flags & attrib) \
- strncat(buf, #attrib" ", 64);
+ strncat(buf, #attrib" ", 64);
if ((buf = calloc(1, 1024)) == NULL)
- abort();
+ abort();
snprintf(buf, 1024, "flags = %d (", kev->flags);
KEVFL_DUMP(EV_ADD);
@@ -208,17 +208,17 @@ kevent_to_str(struct kevent *kev)
snprintf(&buf[0], sizeof(buf),
"[ident=%ju, filter=%d, %s, %s, data=%jd, udata=%p, "
- "ext=[%jx %jx %jx %jx]",
+ "ext=[%jx %jx %jx %jx]",
(uintmax_t) kev->ident,
kev->filter,
flags_str,
fflags_str,
(uintmax_t)kev->data,
kev->udata,
- (uintmax_t)kev->ext[0],
- (uintmax_t)kev->ext[1],
- (uintmax_t)kev->ext[2],
- (uintmax_t)kev->ext[3]);
+ (uintmax_t)kev->ext[0],
+ (uintmax_t)kev->ext[1],
+ (uintmax_t)kev->ext[2],
+ (uintmax_t)kev->ext[3]);
free(flags_str);
free(fflags_str);
@@ -239,10 +239,10 @@ kevent_add(int kqfd, struct kevent *kev,
EV_SET(kev, ident, filter, flags, fflags, data, NULL);
if (kevent(kqfd, kev, 1, NULL, 0, NULL) < 0) {
- kev_str = kevent_to_str(kev);
- printf("Unable to add the following kevent:\n%s\n",
- kev_str);
- free(kev_str);
+ kev_str = kevent_to_str(kev);
+ printf("Unable to add the following kevent:\n%s\n",
+ kev_str);
+ free(kev_str);
err(1, "kevent(): %s", strerror(errno));
}
}
@@ -265,12 +265,12 @@ kevent_cmp(struct kevent *k1, struct kevent *k2)
k1->data != k2->data || k1->udata != k2->udata ||
k1->ext[0] != k2->ext[0] || k1->ext[1] != k2->ext[1] ||
k1->ext[0] != k2->ext[2] || k1->ext[0] != k2->ext[3]) {
- kev1_str = kevent_to_str(k1);
- kev2_str = kevent_to_str(k2);
- printf("kevent_cmp: mismatch:\n %s !=\n %s\n",
- kev1_str, kev2_str);
- free(kev1_str);
- free(kev2_str);
+ kev1_str = kevent_to_str(k1);
+ kev2_str = kevent_to_str(k2);
+ printf("kevent_cmp: mismatch:\n %s !=\n %s\n",
+ kev1_str, kev2_str);
+ free(kev1_str);
+ free(kev2_str);
abort();
}
}
Modified: stable/12/tests/sys/kqueue/libkqueue/proc.c
==============================================================================
--- stable/12/tests/sys/kqueue/libkqueue/proc.c Fri Nov 30 00:47:36 2018 (r341273)
+++ stable/12/tests/sys/kqueue/libkqueue/proc.c Fri Nov 30 01:45:54 2018 (r341274)
@@ -45,7 +45,7 @@ add_and_delete(void)
struct stat s;
if (fstat(kqfd, &s) != -1)
errx(1, "kqueue inherited across fork! (%s() at %s:%d)",
- __func__, __FILE__, __LINE__);
+ __func__, __FILE__, __LINE__);
pause();
exit(2);
Modified: stable/12/tests/sys/kqueue/libkqueue/signal.c
==============================================================================
--- stable/12/tests/sys/kqueue/libkqueue/signal.c Fri Nov 30 00:47:36 2018 (r341273)
+++ stable/12/tests/sys/kqueue/libkqueue/signal.c Fri Nov 30 01:45:54 2018 (r341274)
@@ -188,12 +188,12 @@ test_kevent_signal_oneshot(void)
void
test_evfilt_signal()
{
- kqfd = kqueue();
- test_kevent_signal_add();
- test_kevent_signal_del();
- test_kevent_signal_get();
- test_kevent_signal_disable();
- test_kevent_signal_enable();
- test_kevent_signal_oneshot();
- close(kqfd);
+ kqfd = kqueue();
+ test_kevent_signal_add();
+ test_kevent_signal_del();
+ test_kevent_signal_get();
+ test_kevent_signal_disable();
+ test_kevent_signal_enable();
+ test_kevent_signal_oneshot();
+ close(kqfd);
}
Modified: stable/12/tests/sys/kqueue/libkqueue/timer.c
==============================================================================
--- stable/12/tests/sys/kqueue/libkqueue/timer.c Fri Nov 30 00:47:36 2018 (r341273)
+++ stable/12/tests/sys/kqueue/libkqueue/timer.c Fri Nov 30 01:45:54 2018 (r341274)
@@ -34,11 +34,10 @@ int kqfd;
static long
now(void)
{
-
- struct timeval tv;
+ struct timeval tv;
- gettimeofday(&tv, NULL);
- return SEC_TO_US(tv.tv_sec) + tv.tv_usec;
+ gettimeofday(&tv, NULL);
+ return SEC_TO_US(tv.tv_sec) + tv.tv_usec;
}
/* Sleep for a given number of milliseconds. The timeout is assumed to
@@ -47,13 +46,12 @@ now(void)
void
mssleep(int t)
{
+ struct timespec stime = {
+ .tv_sec = 0,
+ .tv_nsec = US_TO_NS(MS_TO_US(t)),
+ };
- struct timespec stime = {
- .tv_sec = 0,
- .tv_nsec = US_TO_NS(MS_TO_US(t)),
- };
-
- nanosleep(&stime, NULL);
+ nanosleep(&stime, NULL);
}
/* Sleep for a given number of microseconds. The timeout is assumed to
@@ -62,13 +60,12 @@ mssleep(int t)
void
ussleep(int t)
{
+ struct timespec stime = {
+ .tv_sec = 0,
+ .tv_nsec = US_TO_NS(t),
+ };
- struct timespec stime = {
- .tv_sec = 0,
- .tv_nsec = US_TO_NS(t),
- };
-
- nanosleep(&stime, NULL);
+ nanosleep(&stime, NULL);
}
void
@@ -241,7 +238,7 @@ test_abstime(void)
kevent_cmp(&kev, kevent_get(kqfd));
stop = time(NULL);
if (stop < start + timeout)
- err(1, "too early %jd %jd", (intmax_t)stop, (intmax_t)(start + timeout));
+ err(1, "too early %jd %jd", (intmax_t)stop, (intmax_t)(start + timeout));
/* Check if the event occurs again */
sleep(3);
@@ -264,16 +261,16 @@ test_update(void)
/* First set the timer to 1 second */
EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD | EV_ONESHOT,
- NOTE_USECONDS, SEC_TO_US(1), (void *)1);
+ NOTE_USECONDS, SEC_TO_US(1), (void *)1);
start = now();
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
/* Now reduce the timer to 1 ms */
EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD | EV_ONESHOT,
- NOTE_USECONDS, MS_TO_US(1), (void *)2);
+ NOTE_USECONDS, MS_TO_US(1), (void *)2);
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
/* Wait for the event */
kev.flags |= EV_CLEAR;
@@ -288,9 +285,9 @@ test_update(void)
*/
printf("timer expired after %ld us\n", elapsed);
if (elapsed < MS_TO_US(1))
- errx(1, "early timer expiration: %ld us", elapsed);
+ errx(1, "early timer expiration: %ld us", elapsed);
if (elapsed > SEC_TO_US(1))
- errx(1, "late timer expiration: %ld us", elapsed);
+ errx(1, "late timer expiration: %ld us", elapsed);
success();
}
@@ -309,9 +306,9 @@ test_update_equal(void)
/* First set the timer to 1 ms */
EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD | EV_ONESHOT,
- NOTE_USECONDS, MS_TO_US(1), NULL);
+ NOTE_USECONDS, MS_TO_US(1), NULL);
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
/* Sleep for a significant fraction of the timeout. */
ussleep(600);
@@ -319,7 +316,7 @@ test_update_equal(void)
/* Now re-add the timer with the same parameters */
start = now();
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
/* Wait for the event */
kev.flags |= EV_CLEAR;
@@ -334,7 +331,7 @@ test_update_equal(void)
*/
printf("timer expired after %ld us\n", elapsed);
if (elapsed < MS_TO_US(1))
- errx(1, "early timer expiration: %ld us", elapsed);
+ errx(1, "early timer expiration: %ld us", elapsed);
success();
}
@@ -353,9 +350,9 @@ test_update_expired(void)
/* Set the timer to 1ms */
EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD | EV_ONESHOT,
- NOTE_USECONDS, MS_TO_US(1), NULL);
+ NOTE_USECONDS, MS_TO_US(1), NULL);
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
/* Wait for 2 ms to give the timer plenty of time to expire. */
mssleep(2);
@@ -363,7 +360,7 @@ test_update_expired(void)
/* Now re-add the timer */
start = now();
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
/* Wait for the event */
kev.flags |= EV_CLEAR;
@@ -378,7 +375,7 @@ test_update_expired(void)
*/
printf("timer expired after %ld us\n", elapsed);
if (elapsed < MS_TO_US(1))
- errx(1, "early timer expiration: %ld us", elapsed);
+ errx(1, "early timer expiration: %ld us", elapsed);
/* Make sure the re-added timer does not fire. In other words,
* test that the event received above was the only event from the
@@ -405,7 +402,7 @@ test_update_periodic(void)
EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD, 0, SEC_TO_MS(1), NULL);
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
/* Retrieve the event */
kev.flags = EV_ADD | EV_CLEAR;
@@ -420,7 +417,7 @@ test_update_periodic(void)
EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD, 0, SEC_TO_MS(2), NULL);
start = now();
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
/* Retrieve the event */
kev.flags = EV_ADD | EV_CLEAR;
@@ -434,12 +431,12 @@ test_update_periodic(void)
*/
printf("timer expired after %ld us\n", elapsed);
if (elapsed < MS_TO_US(2))
- errx(1, "early timer expiration: %ld us", elapsed);
+ errx(1, "early timer expiration: %ld us", elapsed);
/* Delete the event */
kev.flags = EV_DELETE;
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
success();
}
@@ -467,46 +464,46 @@ test_update_timing(void)
* received is from the update and not the original timer add.
*/
for (sleeptime = MIN_SLEEP, iteration = 1;
- sleeptime < MAX_SLEEP;
- ++sleeptime, ++iteration) {
+ sleeptime < MAX_SLEEP;
+ ++sleeptime, ++iteration) {
- /* First set the timer to 1 ms */
- EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD | EV_ONESHOT,
- NOTE_USECONDS, MS_TO_US(1), NULL);
- if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ /* First set the timer to 1 ms */
+ EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD | EV_ONESHOT,
+ NOTE_USECONDS, MS_TO_US(1), NULL);
+ if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
+ err(1, "%s", test_id);
- /* Delay; the delay ranges from less than to greater than the
- * timer period.
- */
- ussleep(sleeptime);
+ /* Delay; the delay ranges from less than to greater than the
+ * timer period.
+ */
+ ussleep(sleeptime);
- /* Now re-add the timer with the same parameters */
- start = now();
- if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ /* Now re-add the timer with the same parameters */
+ start = now();
+ if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
+ err(1, "%s", test_id);
- /* Wait for the event */
- kev.flags |= EV_CLEAR;
- kev.fflags &= ~NOTE_USECONDS;
- kev.data = 1;
- kevent_cmp(&kev, kevent_get(kqfd));
- stop = now();
- elapsed = stop - start;
+ /* Wait for the event */
+ kev.flags |= EV_CLEAR;
+ kev.fflags &= ~NOTE_USECONDS;
+ kev.data = 1;
+ kevent_cmp(&kev, kevent_get(kqfd));
+ stop = now();
+ elapsed = stop - start;
- /* Check that the timer expired after at least 1 ms. This
- * check is to make sure that the timer re-started and that
- * the event is not from the original add of the timer.
- */
- if (elapsed < MS_TO_US(1))
- errx(1, "early timer expiration: %ld us", elapsed);
+ /* Check that the timer expired after at least 1 ms. This
+ * check is to make sure that the timer re-started and that
+ * the event is not from the original add of the timer.
+ */
+ if (elapsed < MS_TO_US(1))
+ errx(1, "early timer expiration: %ld us", elapsed);
- /* Make sure the re-added timer does not fire. In other words,
- * test that the event received above was the only event from
- * the add and re-add of the timer.
- */
- mssleep(2);
- test_no_kevents_quietly();
+ /* Make sure the re-added timer does not fire. In other words,
+ * test that the event received above was the only event from
+ * the add and re-add of the timer.
+ */
+ mssleep(2);
+ test_no_kevents_quietly();
}
success();
@@ -515,18 +512,18 @@ test_update_timing(void)
void
test_evfilt_timer()
{
- kqfd = kqueue();
- test_kevent_timer_add();
- test_kevent_timer_del();
- test_kevent_timer_get();
- test_oneshot();
- test_periodic();
- test_abstime();
- test_update();
- test_update_equal();
- test_update_expired();
- test_update_timing();
- test_update_periodic();
- disable_and_enable();
- close(kqfd);
+ kqfd = kqueue();
+ test_kevent_timer_add();
+ test_kevent_timer_del();
+ test_kevent_timer_get();
+ test_oneshot();
+ test_periodic();
+ test_abstime();
+ test_update();
+ test_update_equal();
+ test_update_expired();
+ test_update_timing();
+ test_update_periodic();
+ disable_and_enable();
+ close(kqfd);
}
Modified: stable/12/tests/sys/kqueue/libkqueue/user.c
==============================================================================
--- stable/12/tests/sys/kqueue/libkqueue/user.c Fri Nov 30 00:47:36 2018 (r341273)
+++ stable/12/tests/sys/kqueue/libkqueue/user.c Fri Nov 30 01:45:54 2018 (r341274)
@@ -117,7 +117,7 @@ oneshot(void)
void
test_evfilt_user()
{
- kqfd = kqueue();
+ kqfd = kqueue();
add_and_delete();
event_wait();
@@ -125,5 +125,5 @@ test_evfilt_user()
oneshot();
/* TODO: try different fflags operations */
- close(kqfd);
+ close(kqfd);
}
Modified: stable/12/tests/sys/kqueue/libkqueue/vnode.c
==============================================================================
--- stable/12/tests/sys/kqueue/libkqueue/vnode.c Fri Nov 30 00:47:36 2018 (r341273)
+++ stable/12/tests/sys/kqueue/libkqueue/vnode.c Fri Nov 30 01:45:54 2018 (r341274)
@@ -251,16 +251,16 @@ test_kevent_vnode_dispatch(void)
void
test_evfilt_vnode()
{
- kqfd = kqueue();
- test_kevent_vnode_add();
- test_kevent_vnode_del();
- test_kevent_vnode_disable_and_enable();
+ kqfd = kqueue();
+ test_kevent_vnode_add();
+ test_kevent_vnode_del();
+ test_kevent_vnode_disable_and_enable();
#if HAVE_EV_DISPATCH
- test_kevent_vnode_dispatch();
+ test_kevent_vnode_dispatch();
#endif
- test_kevent_vnode_note_write();
- test_kevent_vnode_note_attrib();
- test_kevent_vnode_note_rename();
- test_kevent_vnode_note_delete();
- close(kqfd);
+ test_kevent_vnode_note_write();
+ test_kevent_vnode_note_attrib();
+ test_kevent_vnode_note_rename();
+ test_kevent_vnode_note_delete();
+ close(kqfd);
}
More information about the svn-src-stable
mailing list