File: savesynctest.c

package info (click to toggle)
tinyssh 20230101-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,244 kB
  • sloc: ansic: 12,106; sh: 1,168; python: 479; makefile: 42
file content (37 lines) | stat: -rw-r--r-- 728 bytes parent folder | download | duplicates (4)
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
/*
20140417
Jan Mojzis
Public domain.
*/

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include "fail.h"
#include "randombytes.h"
#include "byte.h"
#include "load.h"
#include "savesync.h"
#include "writeall.h"

#define SPACELEN 1048577

unsigned char space1[SPACELEN];
unsigned char space2[SPACELEN];

static void test1(void) {


    randombytes(space1, sizeof space1);

    if (savesync("savesynctest.data", space1, sizeof space1) == -1) fail("savesync() failure");
    if (load("savesynctest.data", space2, sizeof space2) == -1) fail("load() failure");
    if (!byte_isequal(space1, SPACELEN, space2)) fail("load()/savesync() failure");

}

int main(void) {
    test1();
    _exit(0);
}