File: verify_test.c

package info (click to toggle)
cdparanoia 3a9-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 556 kB
  • ctags: 530
  • sloc: ansic: 6,535; sh: 1,238; makefile: 33
file content (48 lines) | stat: -rw-r--r-- 817 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * Copyright: GNU Public License 2 applies
 *
 * test for debugging purposes with the file based test
 * interface
 */

#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include "interface/cdda_interface.h"

int main(void){
  int i=0;
  size16 a;
  size16 b;

  int in=open("cdda.raw",O_RDONLY);
  int in2=open("test.file",O_RDONLY);
  if(in==-1){
    perror("Unable to open cdda.raw");
    exit(1);
  }
  if(in2==-1){
    perror("Unable to open test.file");
    exit(1);
  }

  while(1){
    if(read(in,&a,2)==-1)break;
    if(read(in2,&b,2)==-1)break;
    if(a!=b)goto fail2;
    i+=2;
  }

  printf("All OK.\n\n");
  close(in);
  close(in2);
  return(0);

fail:
  printf("read error\n");
fail2:
  printf("%d!=%d @ byte position %ld\nfail.\n",(int)a,(int)b,i);
  close(in);
  close(in2);
  return(1);
}