From 9b0067aa4a91b10cbd67ab27daa7fd8d88ade312 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Wed, 8 Jun 2011 08:33:30 +0300 Subject: [PATCH] * add mailing list test msg for unit tests --- src/tests/Makefile.am | 1 + src/tests/test-mu-msg.c | 37 ++++++++++++++++++++--- src/tests/testdir2/bar/cur/181736.eml | 42 +++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 src/tests/testdir2/bar/cur/181736.eml diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index 29ab71bb..c9cf0786 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -117,5 +117,6 @@ EXTRA_DIST= \ testdir2/bar/cur/mail4 \ testdir2/bar/cur/mail5 \ testdir2/Foo/cur/mail5 \ + testdir2/bar/cur/181736.eml \ testdir2/Foo/cur/arto.eml diff --git a/src/tests/test-mu-msg.c b/src/tests/test-mu-msg.c index cda44f4b..6d8bc363 100644 --- a/src/tests/test-mu-msg.c +++ b/src/tests/test-mu-msg.c @@ -1,5 +1,4 @@ /* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/ - /* ** Copyright (C) 2008-2011 Dirk-Jan C. Binnema ** @@ -218,7 +217,7 @@ test_mu_msg_04 (void) static void -test_mu_msg_05 (void) +test_mu_msg_umlaut (void) { MuMsg *msg; @@ -266,12 +265,38 @@ test_mu_msg_tags (void) g_assert_cmpstr ((char*)tags->data,==,"paradise"); g_assert_cmpstr ((char*)tags->next->data,==,"lost"); g_assert (tags->next->next == NULL); + + + mu_msg_unref (msg); +} + + +static void +test_mu_msg_comp_unix_programmer (void) +{ + MuMsg *msg; + + msg = mu_msg_new_from_file (MU_TESTMAILDIR2 + "bar/cur/181736.eml", NULL, NULL); + + g_assert_cmpstr (mu_msg_get_to(msg), + ==, NULL); + g_assert_cmpstr (mu_msg_get_subject(msg), + ==, "Re: Are writes \"atomic\" to readers of the file?"); + g_assert_cmpstr (mu_msg_get_from(msg), + ==, "Jimbo Foobarcuux "); + g_assert_cmpstr (mu_msg_get_msgid(msg), + ==, "oktdp.42997$Te.22361@news.usenetserver.com"); + + //"jimbo@slp53.sl.home (Jimbo Foobarcuux)"; + g_assert_cmpuint (mu_msg_get_prio(msg), /* 'low' */ + ==, MU_MSG_PRIO_NORMAL); + g_assert_cmpuint (mu_msg_get_date(msg), + ==, 1299603860); mu_msg_unref (msg); } - - /* static gboolean */ /* ignore_error (const char* log_domain, GLogLevelFlags log_level, const gchar* msg, */ /* gpointer user_data) */ @@ -299,6 +324,10 @@ main (int argc, char *argv[]) test_mu_msg_05); g_test_add_func ("/mu-msg/mu-msg-tags", test_mu_msg_tags); + g_test_add_func ("/mu-msg/mu-msg-umlaut", + test_mu_msg_umlaut); + g_test_add_func ("/mu-msg/mu-msg-comp-unix-programmer", + test_mu_msg_comp_unix_programmer); g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION, diff --git a/src/tests/testdir2/bar/cur/181736.eml b/src/tests/testdir2/bar/cur/181736.eml new file mode 100644 index 00000000..56255c45 --- /dev/null +++ b/src/tests/testdir2/bar/cur/181736.eml @@ -0,0 +1,42 @@ +Path: uutiset.elisa.fi!feeder2.news.elisa.fi!feeder.erje.net!newsfeed.kamp.net!newsfeed0.kamp.net!nx02.iad01.newshosting.com!newshosting.com!post01.iad!not-for-mail +X-newsreader: xrn 9.03-beta-14-64bit +Sender: jimbo@lews (Jimbo Foobarcuux) +From: jimbo@slp53.sl.home (Jimbo Foobarcuux) +Reply-To: slp53@pacbell.net +Subject: Re: Are writes "atomic" to readers of the file? +Newsgroups: comp.unix.programmer +References: <87hbblwelr.fsf@sapphire.mobileactivedefense.com> <8762s0jreh.fsf@sapphire.mobileactivedefense.com> <87hbbjc5jt.fsf@sapphire.mobileactivedefense.com> <8ioh48-8mu.ln1@leafnode-msgid.gclare.org.uk> +Organization: UseNetServer - www.usenetserver.com +X-Complaints-To: abuse@usenetserver.com +Message-ID: +Date: 08 Mar 2011 17:04:20 GMT +Lines: 27 +Xref: uutiset.elisa.fi comp.unix.programmer:181736 + +John Denver writes: +>Eric the Red wrote: +> +>>> There _IS_ a requirement that all reads and writes to regular files +>>> be atomic. There is also an ordering guarantee. Any implementation +>>> that doesn't provide both atomicity and ordering guarantees is broken. +>> +>> But where is it specified? +> +>The place where it is stated most explicitly is in XSH7 2.9.7 +>Thread Interactions with Regular File Operations: +> +> All of the following functions shall be atomic with respect to each +> other in the effects specified in POSIX.1-2008 when they operate on +> regular files or symbolic links: +> +> [List of functions that includes read() and write()] +> +> If two threads each call one of these functions, each call shall +> either see all of the specified effects of the other call, or none +> of them. +> + +And, for the purposes of this paragraph, the two threads need not be +part of the same process. + +jimbo