0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00
mongodb/db/tests.cpp

68 lines
1.6 KiB
C++
Raw Normal View History

/**
* Copyright (C) 2008 10gen Inc.
2008-12-29 02:28:49 +01:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
2008-12-29 02:28:49 +01:00
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
2008-12-29 02:28:49 +01:00
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2008-06-26 15:09:19 +02:00
/* tests.cpp
unit test & such
*/
#include "stdafx.h"
2008-06-26 21:05:14 +02:00
#include "../util/mmap.h"
2008-06-26 15:09:19 +02:00
2009-01-14 23:09:51 +01:00
namespace mongo {
int test2_old9() {
out() << "test2" << endl;
printStackTrace();
if ( 1 )
return 1;
2008-12-29 02:28:49 +01:00
MemoryMappedFile f;
2008-12-29 02:28:49 +01:00
char *p = (char *) f.map("/tmp/test.dat", 64*1024*1024);
char *start = p;
char *end = p + 64*1024*1024-2;
end[1] = 'z';
int i;
while ( p < end ) {
*p++ = ' ';
if ( ++i%64 == 0 ) {
*p++ = '\n';
*p++ = 'x';
}
2008-12-29 02:28:49 +01:00
}
*p = 'a';
2008-12-29 02:28:49 +01:00
f.flush(true);
out() << "done" << endl;
2008-12-29 02:28:49 +01:00
char *x = start + 32 * 1024 * 1024;
char *y = start + 48 * 1024 * 1024;
char *z = start + 62 * 1024 * 1024;
2008-12-29 02:28:49 +01:00
strcpy(z, "zfoo");
out() << "y" << endl;
strcpy(y, "yfoo");
strcpy(x, "xfoo");
strcpy(start, "xfoo");
2008-12-29 02:28:49 +01:00
exit(3);
2008-12-29 02:28:49 +01:00
return 1;
}
2009-01-14 23:09:51 +01:00
} // namespace mongo