2008-07-20 23:37:33 +02:00
|
|
|
/**
|
|
|
|
* Copyright (C) 2008 10gen Inc.
|
2008-12-29 02:28:49 +01:00
|
|
|
*
|
2008-07-20 23:37:33 +02: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
|
|
|
*
|
2008-07-20 23:37:33 +02: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
|
|
|
*
|
2008-07-20 23:37:33 +02: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 {
|
|
|
|
|
2009-01-18 23:48:44 +01:00
|
|
|
int test2_old9() {
|
2009-01-15 17:26:38 +01:00
|
|
|
out() << "test2" << endl;
|
2009-01-15 16:17:11 +01:00
|
|
|
printStackTrace();
|
|
|
|
if ( 1 )
|
|
|
|
return 1;
|
2008-12-29 02:28:49 +01:00
|
|
|
|
2009-01-15 16:17:11 +01:00
|
|
|
MemoryMappedFile f;
|
2008-12-29 02:28:49 +01:00
|
|
|
|
2009-01-15 16:17:11 +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
|
|
|
}
|
2009-01-15 16:17:11 +01:00
|
|
|
*p = 'a';
|
2008-12-29 02:28:49 +01:00
|
|
|
|
2009-01-15 16:17:11 +01:00
|
|
|
f.flush(true);
|
2009-01-15 17:26:38 +01:00
|
|
|
out() << "done" << endl;
|
2008-12-29 02:28:49 +01:00
|
|
|
|
2009-01-15 16:17:11 +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
|
|
|
|
2009-01-15 16:17:11 +01:00
|
|
|
strcpy(z, "zfoo");
|
2009-01-15 17:26:38 +01:00
|
|
|
out() << "y" << endl;
|
2009-01-15 16:17:11 +01:00
|
|
|
strcpy(y, "yfoo");
|
|
|
|
strcpy(x, "xfoo");
|
|
|
|
strcpy(start, "xfoo");
|
2008-12-29 02:28:49 +01:00
|
|
|
|
2009-01-15 16:17:11 +01:00
|
|
|
exit(3);
|
2008-12-29 02:28:49 +01:00
|
|
|
|
2009-01-15 16:17:11 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2009-01-14 23:09:51 +01:00
|
|
|
|
|
|
|
} // namespace mongo
|