Re: svn commit: r347229 - in head: lib/libsbuf lib/libsbuf/tests share/man/man9 sys/kern sys/sys
On Tue, May 07, 2019 at 05:47:20PM +, Conrad Meyer wrote: > Author: cem > Date: Tue May 7 17:47:20 2019 > New Revision: 347229 > URL: https://svnweb.freebsd.org/changeset/base/347229 > > Log: > device_printf: Use sbuf for more coherent prints on SMP > > device_printf does multiple calls to printf allowing other console messages > to > be inserted between the device name, and the rest of the message. This > change > uses sbuf to compose to two into a single buffer, and prints it all at once. > > It exposes an sbuf drain function (drain-to-printf) for common use. > > Update documentation to match; some unit tests included. > > Submitted by: jmg > Sponsored by: Dell EMC Isilon > Differential Revision: https://reviews.freebsd.org/D16690 > > Modified: > head/lib/libsbuf/Symbol.map > head/lib/libsbuf/tests/sbuf_core_test.c > head/lib/libsbuf/tests/sbuf_stdio_test.c > head/share/man/man9/Makefile > head/share/man/man9/sbuf.9 > head/sys/kern/kern_sysctl.c > head/sys/kern/subr_bus.c > head/sys/kern/subr_prf.c > head/sys/sys/sbuf.h > > Modified: head/lib/libsbuf/Symbol.map > == > --- head/lib/libsbuf/Symbol.map Tue May 7 16:17:33 2019 > (r347228) > +++ head/lib/libsbuf/Symbol.map Tue May 7 17:47:20 2019 > (r347229) > @@ -37,5 +37,6 @@ FBSD_1.4 { > > FBSD_1.5 { > sbuf_putbuf; > + sbuf_printf_drain; > }; The version is wrong. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r347229 - in head: lib/libsbuf lib/libsbuf/tests share/man/man9 sys/kern sys/sys
One correction On Tue, May 7, 2019 at 10:47 AM Conrad Meyer wrote: > Author: cem > Date: Tue May 7 17:47:20 2019 > New Revision: 347229 > URL: https://svnweb.freebsd.org/changeset/base/347229 > > Log: > device_printf: Use sbuf for more coherent prints on SMP > > device_printf does multiple calls to printf allowing other console > messages to > be inserted between the device name, and the rest of the message. This > change > uses sbuf to compose to two into a single buffer, and prints it all at > once. > > It exposes an sbuf drain function (drain-to-printf) for common use. > > Update documentation to match; some unit tests included. > > Submitted by: jmg > Sponsored by: Dell EMC Isilon ^^^ Sorry, I added this on autopilot. It was fully jmg@‘s work. > Differential Revision:https://reviews.freebsd.org/D16690 > ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r347229 - in head: lib/libsbuf lib/libsbuf/tests share/man/man9 sys/kern sys/sys
> Author: cem > Date: Tue May 7 17:47:20 2019 > New Revision: 347229 > URL: https://svnweb.freebsd.org/changeset/base/347229 > > Log: > device_printf: Use sbuf for more coherent prints on SMP > > device_printf does multiple calls to printf allowing other console messages > to > be inserted between the device name, and the rest of the message. This > change > uses sbuf to compose to two into a single buffer, and prints it all at once. > > It exposes an sbuf drain function (drain-to-printf) for common use. > > Update documentation to match; some unit tests included. > > Submitted by: jmg > Sponsored by: Dell EMC Isilon > Differential Revision: https://reviews.freebsd.org/D16690 Thank you! this has been annoying me for a while, I knew it was going on, but wasnt sure where it was coming from. Does this code MFC back to 12 and 11 easily? > Modified: > head/lib/libsbuf/Symbol.map > head/lib/libsbuf/tests/sbuf_core_test.c > head/lib/libsbuf/tests/sbuf_stdio_test.c > head/share/man/man9/Makefile > head/share/man/man9/sbuf.9 > head/sys/kern/kern_sysctl.c > head/sys/kern/subr_bus.c > head/sys/kern/subr_prf.c > head/sys/sys/sbuf.h > > Modified: head/lib/libsbuf/Symbol.map > == > --- head/lib/libsbuf/Symbol.map Tue May 7 16:17:33 2019 > (r347228) > +++ head/lib/libsbuf/Symbol.map Tue May 7 17:47:20 2019 > (r347229) > @@ -37,5 +37,6 @@ FBSD_1.4 { > > FBSD_1.5 { > sbuf_putbuf; > + sbuf_printf_drain; > }; > > > Modified: head/lib/libsbuf/tests/sbuf_core_test.c > == > --- head/lib/libsbuf/tests/sbuf_core_test.c Tue May 7 16:17:33 2019 > (r347228) > +++ head/lib/libsbuf/tests/sbuf_core_test.c Tue May 7 17:47:20 2019 > (r347229) > @@ -63,6 +63,9 @@ ATF_TC_BODY(sbuf_clear_test, tc) >*/ > child_proc = atf_utils_fork(); > if (child_proc == 0) { > + ATF_REQUIRE_EQ_MSG(0, sbuf_finish(sb), "sbuf_finish failed: %s", > + strerror(errno)); > + > sbuf_putbuf(sb); > exit(0); > } > @@ -100,6 +103,34 @@ ATF_TC_BODY(sbuf_done_and_sbuf_finish_test, tc) > sbuf_delete(sb); > } > > +static int > +drain_ret0(void *arg, const char *data, int len) > +{ > + > + (void)arg; > + (void)data; > + (void)len; > + > + return (0); > +} > + > +ATF_TC_WITHOUT_HEAD(sbuf_drain_ret0_test); > +ATF_TC_BODY(sbuf_drain_ret0_test, tc) > +{ > + struct sbuf *sb; > + > + sb = sbuf_new_auto(); > + > + sbuf_set_drain(sb, drain_ret0, NULL); > + > + sbuf_cat(sb, test_string); > + > + ATF_CHECK_EQ_MSG(-1, sbuf_finish(sb), > + "required to return error when drain func returns 0"); > + ATF_CHECK_EQ_MSG(EDEADLK, errno, > + "errno required to be EDEADLK when drain func returns 0"); > +} > + > ATF_TC_WITHOUT_HEAD(sbuf_len_test); > ATF_TC_BODY(sbuf_len_test, tc) > { > @@ -131,6 +162,34 @@ ATF_TC_BODY(sbuf_len_test, tc) > sbuf_delete(sb); > } > > +ATF_TC_WITHOUT_HEAD(sbuf_new_fixedlen); > +ATF_TC_BODY(sbuf_new_fixedlen, tc) > +{ > + char buf[strlen(test_string) + 1]; > + struct sbuf sb; > + pid_t child_proc; > + > + sbuf_new(, buf, sizeof(buf), SBUF_FIXEDLEN); > + > + sbuf_cat(, test_string); > + > + child_proc = atf_utils_fork(); > + if (child_proc == 0) { > + ATF_REQUIRE_EQ_MSG(0, sbuf_finish(), "sbuf_finish failed: > %s", > + strerror(errno)); > + > + sbuf_putbuf(); > + exit(0); > + } > + atf_utils_wait(child_proc, 0, test_string, ""); > + > + sbuf_putc(, ' '); > + > + ATF_CHECK_EQ_MSG(-1, sbuf_finish(), "failed to return error on > overflow"); > + > + sbuf_delete(); > +} > + > ATF_TC_WITHOUT_HEAD(sbuf_setpos_test); > ATF_TC_BODY(sbuf_setpos_test, tc) > { > @@ -190,7 +249,9 @@ ATF_TP_ADD_TCS(tp) > > ATF_TP_ADD_TC(tp, sbuf_clear_test); > ATF_TP_ADD_TC(tp, sbuf_done_and_sbuf_finish_test); > + ATF_TP_ADD_TC(tp, sbuf_drain_ret0_test); > ATF_TP_ADD_TC(tp, sbuf_len_test); > + ATF_TP_ADD_TC(tp, sbuf_new_fixedlen); > #if 0 > /* TODO */ > #ifdef HAVE_SBUF_CLEAR_FLAGS > > Modified: head/lib/libsbuf/tests/sbuf_stdio_test.c > == > --- head/lib/libsbuf/tests/sbuf_stdio_test.c Tue May 7 16:17:33 2019 > (r347228) > +++ head/lib/libsbuf/tests/sbuf_stdio_test.c Tue May 7 17:47:20 2019 > (r347229) > @@ -59,6 +59,60 @@ sbuf_vprintf_helper(struct sbuf *sb, const char * rest > return (rc); > } > > +ATF_TC_WITHOUT_HEAD(sbuf_printf_drain_null_test); > +ATF_TC_BODY(sbuf_printf_drain_null_test, tc) > +{ > + struct sbuf *sb; > + char buf[2]; > + pid_t child_proc; > + > + sb = sbuf_new(NULL,
svn commit: r347229 - in head: lib/libsbuf lib/libsbuf/tests share/man/man9 sys/kern sys/sys
Author: cem Date: Tue May 7 17:47:20 2019 New Revision: 347229 URL: https://svnweb.freebsd.org/changeset/base/347229 Log: device_printf: Use sbuf for more coherent prints on SMP device_printf does multiple calls to printf allowing other console messages to be inserted between the device name, and the rest of the message. This change uses sbuf to compose to two into a single buffer, and prints it all at once. It exposes an sbuf drain function (drain-to-printf) for common use. Update documentation to match; some unit tests included. Submitted by: jmg Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D16690 Modified: head/lib/libsbuf/Symbol.map head/lib/libsbuf/tests/sbuf_core_test.c head/lib/libsbuf/tests/sbuf_stdio_test.c head/share/man/man9/Makefile head/share/man/man9/sbuf.9 head/sys/kern/kern_sysctl.c head/sys/kern/subr_bus.c head/sys/kern/subr_prf.c head/sys/sys/sbuf.h Modified: head/lib/libsbuf/Symbol.map == --- head/lib/libsbuf/Symbol.map Tue May 7 16:17:33 2019(r347228) +++ head/lib/libsbuf/Symbol.map Tue May 7 17:47:20 2019(r347229) @@ -37,5 +37,6 @@ FBSD_1.4 { FBSD_1.5 { sbuf_putbuf; + sbuf_printf_drain; }; Modified: head/lib/libsbuf/tests/sbuf_core_test.c == --- head/lib/libsbuf/tests/sbuf_core_test.c Tue May 7 16:17:33 2019 (r347228) +++ head/lib/libsbuf/tests/sbuf_core_test.c Tue May 7 17:47:20 2019 (r347229) @@ -63,6 +63,9 @@ ATF_TC_BODY(sbuf_clear_test, tc) */ child_proc = atf_utils_fork(); if (child_proc == 0) { + ATF_REQUIRE_EQ_MSG(0, sbuf_finish(sb), "sbuf_finish failed: %s", + strerror(errno)); + sbuf_putbuf(sb); exit(0); } @@ -100,6 +103,34 @@ ATF_TC_BODY(sbuf_done_and_sbuf_finish_test, tc) sbuf_delete(sb); } +static int +drain_ret0(void *arg, const char *data, int len) +{ + + (void)arg; + (void)data; + (void)len; + + return (0); +} + +ATF_TC_WITHOUT_HEAD(sbuf_drain_ret0_test); +ATF_TC_BODY(sbuf_drain_ret0_test, tc) +{ + struct sbuf *sb; + + sb = sbuf_new_auto(); + + sbuf_set_drain(sb, drain_ret0, NULL); + + sbuf_cat(sb, test_string); + + ATF_CHECK_EQ_MSG(-1, sbuf_finish(sb), + "required to return error when drain func returns 0"); + ATF_CHECK_EQ_MSG(EDEADLK, errno, + "errno required to be EDEADLK when drain func returns 0"); +} + ATF_TC_WITHOUT_HEAD(sbuf_len_test); ATF_TC_BODY(sbuf_len_test, tc) { @@ -131,6 +162,34 @@ ATF_TC_BODY(sbuf_len_test, tc) sbuf_delete(sb); } +ATF_TC_WITHOUT_HEAD(sbuf_new_fixedlen); +ATF_TC_BODY(sbuf_new_fixedlen, tc) +{ + char buf[strlen(test_string) + 1]; + struct sbuf sb; + pid_t child_proc; + + sbuf_new(, buf, sizeof(buf), SBUF_FIXEDLEN); + + sbuf_cat(, test_string); + + child_proc = atf_utils_fork(); + if (child_proc == 0) { + ATF_REQUIRE_EQ_MSG(0, sbuf_finish(), "sbuf_finish failed: %s", + strerror(errno)); + + sbuf_putbuf(); + exit(0); + } + atf_utils_wait(child_proc, 0, test_string, ""); + + sbuf_putc(, ' '); + + ATF_CHECK_EQ_MSG(-1, sbuf_finish(), "failed to return error on overflow"); + + sbuf_delete(); +} + ATF_TC_WITHOUT_HEAD(sbuf_setpos_test); ATF_TC_BODY(sbuf_setpos_test, tc) { @@ -190,7 +249,9 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, sbuf_clear_test); ATF_TP_ADD_TC(tp, sbuf_done_and_sbuf_finish_test); + ATF_TP_ADD_TC(tp, sbuf_drain_ret0_test); ATF_TP_ADD_TC(tp, sbuf_len_test); + ATF_TP_ADD_TC(tp, sbuf_new_fixedlen); #if 0 /* TODO */ #ifdef HAVE_SBUF_CLEAR_FLAGS Modified: head/lib/libsbuf/tests/sbuf_stdio_test.c == --- head/lib/libsbuf/tests/sbuf_stdio_test.cTue May 7 16:17:33 2019 (r347228) +++ head/lib/libsbuf/tests/sbuf_stdio_test.cTue May 7 17:47:20 2019 (r347229) @@ -59,6 +59,60 @@ sbuf_vprintf_helper(struct sbuf *sb, const char * rest return (rc); } +ATF_TC_WITHOUT_HEAD(sbuf_printf_drain_null_test); +ATF_TC_BODY(sbuf_printf_drain_null_test, tc) +{ + struct sbuf *sb; + char buf[2]; + pid_t child_proc; + + sb = sbuf_new(NULL, buf, sizeof(buf), SBUF_FIXEDLEN); + ATF_REQUIRE_MSG(sb != NULL, "sbuf_new_auto failed: %s", + strerror(errno)); + + child_proc = atf_utils_fork(); + if (child_proc == 0) { + sbuf_set_drain(sb, sbuf_printf_drain, NULL); + + ATF_REQUIRE_EQ_MSG(0, sbuf_cat(sb, test_string), + "sbuf_cat failed"); + + ATF_CHECK_EQ(0,