pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

libcanlock: Added patches for test target (to work without V2 API)



Module Name:	pkgsrc-wip
Committed By:	Michael Baeuerle <michael.baeuerle%stz-e.de@localhost>
Pushed By:	micha
Date:		Fri Aug 17 14:58:05 2018 +0200
Changeset:	1841721bfae13119087d0290b9c70213ffd4357d

Modified Files:
	libcanlock/Makefile
	libcanlock/distinfo
Added Files:
	libcanlock/patches/patch-test_canlocktest.c
	libcanlock/patches/patch-test_canlocktest__legacy.c

Log Message:
libcanlock: Added patches for test target (to work without V2 API)

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=1841721bfae13119087d0290b9c70213ffd4357d

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 libcanlock/Makefile                                |  2 +-
 libcanlock/distinfo                                |  2 +
 libcanlock/patches/patch-test_canlocktest.c        | 67 ++++++++++++++++++++++
 .../patches/patch-test_canlocktest__legacy.c       | 36 ++++++++++++
 4 files changed, 106 insertions(+), 1 deletion(-)

diffs:
diff --git a/libcanlock/Makefile b/libcanlock/Makefile
index f6aa945dea..d02a6073fd 100644
--- a/libcanlock/Makefile
+++ b/libcanlock/Makefile
@@ -19,7 +19,7 @@ TEST_TARGET=	test
 
 # Disable obsolete Version 2 API
 SUBST_CLASSES+=			edit-header
-SUBST_STAGE.edit-header=	pre-configure
+SUBST_STAGE.edit-header=	post-patch
 SUBST_MESSAGE.edit-header=	Prepare header file
 SUBST_FILES.edit-header=	include/canlock.h
 SUBST_SED.edit-header=		-e 's,CL_API_V2  1,CL_API_V2  0,g'
diff --git a/libcanlock/distinfo b/libcanlock/distinfo
index 2ac8876fbd..e14ff12649 100644
--- a/libcanlock/distinfo
+++ b/libcanlock/distinfo
@@ -4,3 +4,5 @@ SHA1 (libcanlock-3.0.1.tar.bz2) = 609f3c5e6e5cefbe9c806c0372e258cb5a57d553
 RMD160 (libcanlock-3.0.1.tar.bz2) = c118b3ee8ac981e08102ebc105daaeba9d82b51b
 SHA512 (libcanlock-3.0.1.tar.bz2) = ccd4d81c49ab054359885eb1f8e65f1e978c4591a01dc280b029a5d8850b2b92895bd2c34c010da697946b27220f67f36346a6e2439b4e91a9da0c54bf08927c
 Size (libcanlock-3.0.1.tar.bz2) = 316579 bytes
+SHA1 (patch-test_canlocktest.c) = d04b6011f588c580d566e8f9ac6908df45d5ba71
+SHA1 (patch-test_canlocktest__legacy.c) = c6d8788b35d81c43c8cc447b04b912525ea4db44
diff --git a/libcanlock/patches/patch-test_canlocktest.c b/libcanlock/patches/patch-test_canlocktest.c
new file mode 100644
index 0000000000..765679be44
--- /dev/null
+++ b/libcanlock/patches/patch-test_canlocktest.c
@@ -0,0 +1,67 @@
+$NetBSD$
+
+Disable test with <clue-string> and no longer use V2 API.
+
+--- test/canlocktest.c.orig	2017-05-08 14:24:53.000000000 +0000
++++ test/canlocktest.c
+@@ -80,23 +80,21 @@ static const char *check_scheme(cl_hash_
+ static int checker(cl_hash_version hash, char *key, char *lock)
+ {
+    int res = -1;
+-   char *rawkey, *rawlock;
+-   char keytype[BUFFSIZE], locktype[BUFFSIZE];
++   cl_hash_version hash_key, hash_lock;
++   char *string_key, *string_lock;
+    const char *scheme;
+ 
+    printf("%s\n%s,%s\n", "Check Cancel-Key,Cancel-Lock:", key, lock);
+ 
+-   rawkey = lock_strip_alpha(key, keytype);
+-   rawlock = lock_strip_alpha(lock, locktype);
++   hash_key = cl_split(key, &string_key);
++   hash_lock = cl_split(lock, &string_lock);
+ 
+-   /* Check whether <scheme> matches */
+-   if (!strcmp(keytype, locktype))
++   if (hash_key && hash_lock)
+    {
+-      /* Check whether <scheme> is supported */
+-      scheme = check_scheme(hash);
+-      if (NULL != scheme && !strcmp(keytype, scheme))
++      /* Check whether <scheme> matches */
++      if (hash_key == hash_lock)
+       {
+-         if (!cl_verify(hash, rawkey, rawlock))
++         if (!cl_verify(hash, string_key, string_lock))
+          {
+             printf("\nGOOD\n");
+             res = 0;
+@@ -105,10 +103,11 @@ static int checker(cl_hash_version hash,
+             printf("\nBAD\n");
+       }
+       else
+-         printf("\nBAD: Scheme not supported\n");
++         printf("\nBAD: Scheme mismatch (%s/%s)\n",
++                check_scheme(hash_key), check_scheme(hash_lock));
+    }
+    else
+-      printf("\nBAD: Scheme mismatch (%s/%s)\n", keytype, locktype);
++      printf("\nBAD: Scheme not supported\n");
+ 
+    return res;
+ }
+@@ -224,10 +223,14 @@ int main(void)
+ 
+    /* Test 5 (Check SHA1 with <clue-string> element) */
+    printf("Test 5 (Check SHA1 with <clue-string> element)\n\n");
++#if 0  /* Skip because it requires V2 API */
+    c_key = "ShA1:aaaBBBcccDDDeeeFFF:bN";
+    c_lock = "sha1:bNXHc6ohSmeHaRHHW56BIWZJt+4=";
+    rv = checker(CL_SHA1, c_key, c_lock);
+    if (rv) failed = 1;
++#endif
++   printf("SKIP\n");
++   printf("(Note: <clue-string> is obsolete since >20 years)\n");
+    printf("\n----------------------------------------"
+           "----------------------------------------\n\n");
+ 
diff --git a/libcanlock/patches/patch-test_canlocktest__legacy.c b/libcanlock/patches/patch-test_canlocktest__legacy.c
new file mode 100644
index 0000000000..487ea2826a
--- /dev/null
+++ b/libcanlock/patches/patch-test_canlocktest__legacy.c
@@ -0,0 +1,36 @@
+$NetBSD$
+
+Execute legacy tests as NOP if V2 API is disabled.
+
+--- test/canlocktest_legacy.c.orig	2017-05-07 14:53:45.000000000 +0000
++++ test/canlocktest_legacy.c
+@@ -49,6 +49,7 @@
+ #define BUFFSIZE 512
+ 
+ 
++#if CL_API_V2
+ static int checker(char *key, char *lock)
+ {
+    int res = -1;
+@@ -80,10 +81,12 @@ static int checker(char *key, char *lock
+ 
+    return res;
+ }
++#endif  /* CL_API_V2 */
+ 
+ 
+ int main(void)
+ {
++#if CL_API_V2
+    char cankey[256], canlock[256], *lkey, *llock;
+    unsigned char secret[] = "fluffy",
+       message[] = "<lkr905851929.22670@meow.invalid>";
+@@ -146,4 +149,8 @@ int main(void)
+    /* Check for success */
+    if (!failed) exit(EXIT_SUCCESS);
+    exit(EXIT_FAILURE);
++#else  /* CL_API_V2 */
++   /* Without V2 API: Execute as NOP and return success */
++   exit(EXIT_SUCCESS);
++#endif  /* CL_API_V2 */
+ }


Home | Main Index | Thread Index | Old Index