[Pkg-wmaker-commits] [wmbiff] 10/14: check the newline bugfix

Doug Torrance dtorrance-guest at moszumanska.debian.org
Thu Aug 20 03:04:00 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to tag wmbiff_0_4_17
in repository wmbiff.

commit 704c3d5b13e1d029ccd4315f650426813cb0aab0
Author: bluehal <bluehal>
Date:   Sun Aug 31 03:33:11 2003 +0000

    check the newline bugfix
---
 wmbiff/test_wmbiff.c | 64 +++++++++++++++++++++++++++++++++++++++++++++-------
 wmbiff/tlsComm.h     |  4 ++++
 2 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/wmbiff/test_wmbiff.c b/wmbiff/test_wmbiff.c
index 56b3d9d..ecffe46 100644
--- a/wmbiff/test_wmbiff.c
+++ b/wmbiff/test_wmbiff.c
@@ -16,8 +16,11 @@
 #define ENFROB(x)
 #endif
 
+#include <unistd.h>
+
 #include "Client.h"
 #include "passwordMgr.h"
+#include "tlsComm.h"
 
 int debug_default = DEBUG_INFO;
 int Relax = 1;
@@ -276,14 +279,54 @@ int test_imap4creator(void) {
     return 0;
 }
 
-void initialize_blacklist(void) { } 
-void tlscomm_printf(UNUSED(int x), UNUSED(const char *f), ...) { }
-void tlscomm_expect(void) {  } 
-void tlscomm_close() {  } 
-int tlscomm_is_blacklisted(UNUSED(const char *x)) {  return 1; } 
-void initialize_gnutls(void) {  } 
-int sock_connect(UNUSED(const char *n), UNUSED(int p)) { return 1; } /* stdout */
-void initialize_unencrypted(void) {  } 
+
+int test_getline_from_buffer(void) {
+#define LINE_BUF_LEN 256
+    char linebuf[LINE_BUF_LEN];
+    char scratchbuf[LINE_BUF_LEN];
+    
+    /* try to ensure that even an endless loop terminates */
+    alarm(100);
+    strcpy(scratchbuf, "\r\n");
+    getline_from_buffer(scratchbuf, linebuf, LINE_BUF_LEN);
+    if(strlen(scratchbuf) != 0) {
+		printf("FAILURE: scratchbuf not snarfed\n");
+		return(1);
+	}
+    if(strlen(linebuf) != 2) {
+		printf("FAILURE: linebuf not populated\n");
+		return(1);
+	}
+    strcpy(scratchbuf, "\n");
+    getline_from_buffer(scratchbuf, linebuf, LINE_BUF_LEN);
+    if(strlen(scratchbuf) != 0) {
+		printf("FAILURE: scratchbuf not snarfed\n");
+		return(1);
+	}
+    if(strlen(linebuf) != 1) {
+		printf("FAILURE: linebuf not populated\n");
+		return(1);
+	}
+    
+    alarm(0);
+    return(0);
+}
+
+
+int print_info(UNUSED(void * state)) { return(0); }
+const char *certificate_filename = NULL;
+int SkipCertificateCheck = 0;
+int exists(UNUSED(const char *filename)) { return(0); }	
+
+
+// void initialize_blacklist(void) { } 
+// void tlscomm_printf(UNUSED(int x), UNUSED(const char *f), ...) { }
+// void tlscomm_expect(void) {  } 
+// void tlscomm_close() {  } 
+// int tlscomm_is_blacklisted(UNUSED(const char *x)) {  return 1; } 
+// void initialize_gnutls(void) {  } 
+// int sock_connect(UNUSED(const char *n), UNUSED(int p)) { return 1; } /* stdout */
+// void initialize_unencrypted(void) {  } 
 
 int main(UNUSED(int argc), UNUSED(char *argv[])) {
 
@@ -305,6 +348,11 @@ int main(UNUSED(int argc), UNUSED(char *argv[])) {
         exit(EXIT_FAILURE);
     }
 
+    if( test_getline_from_buffer() ) {
+        printf("SOME TESTS FAILED!\n");
+        exit(EXIT_FAILURE);
+    }
+
     printf("Success! on all tests.\n");
     exit(EXIT_SUCCESS);
 }
diff --git a/wmbiff/tlsComm.h b/wmbiff/tlsComm.h
index 5c13433..0ef47d8 100644
--- a/wmbiff/tlsComm.h
+++ b/wmbiff/tlsComm.h
@@ -53,3 +53,7 @@ int tlscomm_expect(struct connection_state *scs, const char *prefix,
 /* terminates the TLS association or just closes the socket,
    and frees the connection state */
 void tlscomm_close( /*@only@ */ struct connection_state *scs);
+
+/* internal function exported for testing */
+int
+getline_from_buffer(char *readbuffer, char *linebuffer, int linebuflen);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbiff.git



More information about the Pkg-wmaker-commits mailing list