TABLE OF CONTENTS


ABINIT/21_hashfuncs/tests/test_md5_sum_from_file [ Programs ]

[ Top ] [ Programs ]

NAME

  test_md5_sum_from_file

FUNCTION

  Unit test for the test_md5_sum_from_file routine of m_hash_md5.

COPYRIGHT

  Copyright (C) 2016-2018 ABINIT Group (Yann Pouillon)
  This file is distributed under the terms of the
  GNU General Public License, see ~abinit/COPYING
  or http://www.gnu.org/copyleft/gpl.txt .
  For the initials of contributors, see
  ~abinit/doc/developers/contributors.txt .

NOTES

  This program is run by "make check".

INPUTS

  (main routine)

OUTPUT

  (main routine)

PARENTS

CHILDREN

SOURCE

 32 #if defined HAVE_CONFIG_H
 33 #include "config.h"
 34 #endif
 35 
 36 program test_md5_sum_from_file
 37 
 38 use defs_basis, only: ch10,fnlen,std_out
 39 use m_hash_md5
 40 
 41 !This section has been created automatically by the script Abilint (TD).
 42 !Do not modify the following lines by hand.
 43 #undef ABI_FUNC
 44 #define ABI_FUNC 'test_md5_sum_from_file'
 45 !End of the abilint section
 46 
 47 implicit none
 48 
 49 character(len=*), parameter  :: abinit_input_string = "ABINIT"
 50 character(len=32), parameter :: abinit_md5_single_line_ref = &
 51 &                                 "1c57f60933157a3b6e13def40286f0c5"
 52 character(len=32), parameter :: abinit_md5_multi_line_ref = &
 53 &                                 "953ac666dcdbf651ee3393d374216499"
 54 
 55 character(len=fnlen), parameter :: tmp_file = "test_md5_sum_from_file.tmp"
 56 
 57 character(len=32) :: chk_value_single, chk_value_multi
 58 logical :: test_ok
 59 
 60 #if defined DEBUG_MODE
 61 write(std_out,'(a,a)') "Unitary test: md5_sum_from_file", ch10
 62 #endif
 63 
 64 ! File of one line + newline character
 65 #if defined DEBUG_MODE
 66 write(std_out,'(1x,a,1x,a)') "Creating single-line ", trim(tmp_file)
 67 write(std_out,'(1x,a," = ",a)') "Reference MD5 sum", abinit_md5_single_line_ref
 68 #endif
 69 
 70 open(unit=1, file=trim(tmp_file), form="formatted", status="replace")
 71 write(1,'(a)') abinit_input_string
 72 close(1)
 73 
 74 chk_value_single = md5_sum_from_file(tmp_file)
 75 
 76 #if defined DEBUG_MODE
 77 write(std_out,'(1x,a," = ",a)') "Computed  MD5 sum", chk_value_single
 78 #endif
 79 
 80 ! File of three lines + newline characters
 81 #if defined DEBUG_MODE
 82 write(std_out,*)
 83 write(std_out,'(1x,a,1x,a)') "Creating multi-line ", trim(tmp_file)
 84 write(std_out,'(1x,a," = ",a)') "Reference MD5 sum", abinit_md5_multi_line_ref
 85 #endif
 86 
 87 open(unit=1, file=trim(tmp_file), form="formatted", status="replace")
 88 write(1,'(a)') abinit_input_string
 89 write(1,'(a)') abinit_input_string
 90 write(1,'(a)') abinit_input_string
 91 close(1)
 92 
 93 chk_value_multi = md5_sum_from_file(tmp_file)
 94 
 95 #if defined DEBUG_MODE
 96 write(std_out,'(1x,a," = ",a)') "Computed  MD5 sum", chk_value_multi
 97 #endif
 98 
 99 ! Report test result
100 test_ok = ( md5_check(abinit_md5_single_line_ref, chk_value_single) .and. &
101 & md5_check(abinit_md5_multi_line_ref, chk_value_multi) )
102 #if defined DEBUG_MODE
103 write(std_out,*)
104 if ( test_ok ) then
105   write(std_out,'(a,a)') "TEST OK", ch10
106 else
107   write(std_out,'(a,a)') "TEST FAILED", ch10
108 end if
109 #else
110 if ( .not. test_ok ) then
111   write(std_out,'(a,a)') "TEST FAILED", ch10
112 end if
113 #endif
114 
115 end program test_md5_sum_from_file