/usr/include/wibble/sys/mmap_v2.test.h is in libwibble-dev 1.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 49 50 51 52 53 | // -*- C++ -*- (c) 2013 Vladimír Štill <xstill@fi.muni.cz>
#if __cplusplus >= 201103L
#include <wibble/sys/mmap_v2.h>
using namespace wibble::sys;
#endif
#include <wibble/test.h>
#include <string.h>
using namespace std;
using namespace wibble;
struct TestMMapV2 {
Test read() {
#if defined POSIX && __cplusplus >= 201103L
MMap map;
assert_eq( map.size(), 0U );
assert( !map );
assert( !map.valid() );
assert( !map.mode() );
map.map( "/bin/sh" );
assert_neq( map.size(), 0U );
assert_eq( map.mode(), MMap::ProtectMode::Read | MMap::ProtectMode::Shared );
assert( map.valid() );
assert_eq( map[ 1 ], 'E' );
assert_eq( map[ 2 ], 'L' );
assert_eq( map[ 3 ], 'F' );
MMap map1 = map; // shared_ptr semantics
assert_eq( map.size(), map.size() );
assert_eq( map.asArrayOf< char >(), map1.asArrayOf< char >() );
assert_eq( map.mode(), map1.mode() );
assert_eq( map1.get< char >( 1 ), 'E' );
assert_eq( map1.get< char >( 2 ), 'L' );
assert_eq( map1.get< char >( 3 ), 'F' );
map1.unmap();
assert_eq( map1.size(), 0U );
assert( !map1 );
assert_eq( map.cget< char >( 1 ), 'E' );
assert_eq( map.cget< char >( 2 ), 'L' );
assert_eq( map.cget< char >( 3 ), 'F' );
assert( map.valid() );
map.unmap();
assert_eq( map.size(), 0U );
assert( !map );
#endif
}
};
|