tests/utils.tpl tests/pcm_test.tpl : Update check_file_hash_or_die to use 64 bit hash.

This commit is contained in:
Erik de Castro Lopo 2008-10-05 15:02:07 +11:00
parent 2abf5b4dfa
commit 5f99d78bdb
3 changed files with 45 additions and 45 deletions

View File

@ -1,3 +1,8 @@
2008-10-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/utils.tpl tests/pcm_test.tpl
Update check_file_hash_or_die to use 64 bit hash.
2008-10-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/gsm610.c

View File

@ -37,11 +37,11 @@
static void lrintf_test (void) ;
[+ FOR data_type
+]static void pcm_test_[+ (get "name") +] (const char *filename, int filetype, int hash) ;
+]static void pcm_test_[+ (get "name") +] (const char *filename, int filetype, uint64_t hash) ;
[+ ENDFOR data_type
+]
static void pcm_test_float (const char *filename, int filetype, int hash, int replace_float) ;
static void pcm_test_double (const char *filename, int filetype, int hash, int replace_float) ;
static void pcm_test_float (const char *filename, int filetype, uint64_t hash, int replace_float) ;
static void pcm_test_double (const char *filename, int filetype, uint64_t hash, int replace_float) ;
typedef union
{ double d [BUFFER_SIZE + 1];
@ -61,32 +61,32 @@ main (void)
{
lrintf_test () ;
pcm_test_bits_8 ("pcm-s8.raw", SF_FORMAT_RAW | SF_FORMAT_PCM_S8, 0x9ae33814) ;
pcm_test_bits_8 ("pcm-u8.raw", SF_FORMAT_RAW | SF_FORMAT_PCM_U8, 0x651d4694) ;
pcm_test_bits_8 ("pcm-s8.raw", SF_FORMAT_RAW | SF_FORMAT_PCM_S8, 0x1cda335091249dbfLL) ;
pcm_test_bits_8 ("pcm-u8.raw", SF_FORMAT_RAW | SF_FORMAT_PCM_U8, 0x7f748c433d695f3fLL) ;
pcm_test_bits_16 ("le-pcm16.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_16, 0x16866fa0) ;
pcm_test_bits_16 ("be-pcm16.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_16, 0xc571826c) ;
pcm_test_bits_16 ("le-pcm16.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_16, 0x3a2b956c881ebf08LL) ;
pcm_test_bits_16 ("be-pcm16.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_16, 0xd9e2f840c55750f8LL) ;
pcm_test_bits_24 ("le-pcm24.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_24, 0x658e4bb6) ;
pcm_test_bits_24 ("be-pcm24.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_24, 0xbf8cde4a) ;
pcm_test_bits_24 ("le-pcm24.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_24, 0x933b6a759ab496f8LL) ;
pcm_test_bits_24 ("be-pcm24.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_24, 0xbb1f3eaf9c30b6f8LL) ;
pcm_test_bits_32 ("le-pcm32.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_32, 0x04c84a70) ;
pcm_test_bits_32 ("be-pcm32.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_32, 0x069c84f6) ;
pcm_test_bits_32 ("le-pcm32.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_32, 0xa77aece1c1c17f08LL) ;
pcm_test_bits_32 ("be-pcm32.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_32, 0x3099ddf142d0b0f8LL) ;
/* Lite remove start */
pcm_test_float ("le-float.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0xbb836603, SF_FALSE) ;
pcm_test_float ("be-float.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x903cd8fc, SF_FALSE) ;
pcm_test_float ("le-float.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x3c2ad04f7554267aLL, SF_FALSE) ;
pcm_test_float ("be-float.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x074de3e248fa9186LL, SF_FALSE) ;
pcm_test_double ("le-double.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xbf84448e, SF_FALSE) ;
pcm_test_double ("be-double.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xaf3d9fb5, SF_FALSE) ;
pcm_test_double ("le-double.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xc682726f958f669cLL, SF_FALSE) ;
pcm_test_double ("be-double.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xd9a3583f8ee51164LL, SF_FALSE) ;
puts ("Test IEEE replacement code.") ;
pcm_test_float ("le-float.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0xbb836603, SF_TRUE) ;
pcm_test_float ("be-float.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x903cd8fc, SF_TRUE) ;
pcm_test_float ("le-float.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x3c2ad04f7554267aLL, SF_TRUE) ;
pcm_test_float ("be-float.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0x074de3e248fa9186LL, SF_TRUE) ;
pcm_test_double ("le-double.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xbf84448e, SF_TRUE) ;
pcm_test_double ("be-double.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xaf3d9fb5, SF_TRUE) ;
pcm_test_double ("le-double.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xc682726f958f669cLL, SF_TRUE) ;
pcm_test_double ("be-double.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0xd9a3583f8ee51164LL, SF_TRUE) ;
/* Lite remove end */
return 0 ;
@ -126,7 +126,7 @@ lrintf_test (void)
[+ FOR data_type
+]static void
pcm_test_[+ (get "name") +] (const char *filename, int filetype, int hash)
pcm_test_[+ (get "name") +] (const char *filename, int filetype, uint64_t hash)
{ SNDFILE *file ;
SF_INFO sfinfo ;
int k, items, zero_count ;
@ -399,7 +399,7 @@ pcm_test_[+ (get "name") +] (const char *filename, int filetype, int hash)
*/
static void
pcm_test_float (const char *filename, int filetype, int hash, int replace_float)
pcm_test_float (const char *filename, int filetype, uint64_t hash, int replace_float)
{ SNDFILE *file ;
SF_INFO sfinfo ;
int k, items, frames ;
@ -653,7 +653,7 @@ pcm_test_float (const char *filename, int filetype, int hash, int replace_float)
} /* pcm_test_float */
static void
pcm_test_double (const char *filename, int filetype, int hash, int replace_float)
pcm_test_double (const char *filename, int filetype, uint64_t hash, int replace_float)
{ SNDFILE *file ;
SF_INFO sfinfo ;
int k, items, frames ;

View File

@ -1,6 +1,6 @@
[+ AutoGen5 template h c +]
/*
** Copyright (C) 2002-2007 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 2002-2008 Erik de Castro Lopo <erikd@mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -52,7 +52,7 @@ extern "C" {
void create_short_sndfile (const char *filename, int format, int channels) ;
void check_file_hash_or_die (const char *filename, unsigned int target_hash, int line_num) ;
void check_file_hash_or_die (const char *filename, uint64_t target_hash, int line_num) ;
void print_test_name (const char *test, const char *filename) ;
@ -138,6 +138,7 @@ sf_count_t file_length_fd (int fd) ;
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#if HAVE_UNISTD_H
#include <unistd.h>
@ -203,7 +204,6 @@ create_short_sndfile (const char *filename, int format, int channels)
{ short data [2 * 3 * 4 * 5 * 6 * 7] = { 0, } ;
SNDFILE *file ;
SF_INFO sfinfo ;
sfinfo.samplerate = 44100 ;
sfinfo.channels = channels ;
@ -220,42 +220,37 @@ create_short_sndfile (const char *filename, int format, int channels)
} /* create_short_sndfile */
void
check_file_hash_or_die (const char *filename, unsigned int target_hash, int line_num)
{ static unsigned char buffer [2048] ;
unsigned int hash1, hash2 ;
FILE *file ;
int k, read_count ;
check_file_hash_or_die (const char *filename, uint64_t target_hash, int line_num)
{ static unsigned char buf [4096] ;
uint64_t cksum ;
FILE *file ;
int k, read_count ;
memset (buffer, 0xEE, sizeof (buffer)) ;
memset (buf, 0, sizeof (buf)) ;
/* The 'b' in the mode string means binary for Win32. */
if (! (file = fopen (filename, "rb")))
if ((file = fopen (filename, "rb")) == NULL)
{ printf ("\n\nLine %d: could not open file '%s'\n\n", line_num, filename) ;
exit (1) ;
} ;
hash1 = hash2 = 0 ;
cksum = 0 ;
while ((read_count = fread (buffer, 1, sizeof (buffer), file)))
{ for (k = 0 ; k < read_count ; k++)
{ hash1 = hash1 + buffer [k] ;
hash2 = hash2 ^ (buffer [k] << (k % 25)) ;
} ;
} ;
while ((read_count = fread (buf, 1, sizeof (buf), file)))
for (k = 0 ; k < read_count ; k++)
cksum = cksum * 511 + buf [k] ;
fclose (file) ;
hash1 += hash2 ;
if (target_hash == 0)
{ printf (" 0x%08x ", hash1) ;
{ printf (" 0x%016" PRIx64 "\n", cksum) ;
return ;
} ;
if (hash1 != target_hash)
{ printf ("\n\nLine %d: incorrect hash value 0x%08x should be 0x%08x\n\n", line_num, hash1, target_hash) ;
if (cksum != target_hash)
{ printf ("\n\nLine %d: incorrect hash value 0x%016" PRIx64 " should be 0x%016" PRIx64 ".\n\n", line_num, cksum, target_hash) ;
exit (1) ;
}
} ;
return ;
} /* check_file_hash_or_die */