TestNormalModeLangevin.cpp 1.26 KB
Newer Older
1
2
3
#include "OpenMM.h"
#include <vector>
#include <string>
4
#include <iostream>
5
#include <cstdlib>
6
7
8
9

using namespace OpenMM;
using namespace std;

10
11
12
13
14
15
16
17
18
19
void mysetenv(const char* name, const char* value) {
#ifdef _MSC_VER
    char buffer[1000];
    sprintf(buffer, "%s=%s", name, value);
    putenv(buffer);
#else
    setenv(name, value, 1);
#endif
}

20
21
void testLoadNMLPlugin() 
{
22
23
24
    string pluginDir = Platform::getDefaultPluginsDirectory();
    cout << "Default plugins directory = " << pluginDir << endl;
    Platform::loadPluginsFromDirectory(pluginDir);
25
26
27
    vector<string> kernelName;
    kernelName.push_back("IntegrateNMLStepKernel");
    // Was NormalModeLangevin plugin loaded?
28
    Platform& platform = Platform::findPlatform(kernelName); // throws if no platform with kernel
29
30
}

31
int main(int argc, const char* argv[]) 
32
{
33
34
    try 
    {
35
36
37
38
39
40
41
        if (argc > 1) {
            const char* plugin_dir = argv[1];
            // 0 => don't set if variable exists
            mysetenv("OPENMM_PLUGIN_DIR", plugin_dir);
            cout << plugin_dir << endl;
            cout << getenv("OPENMM_PLUGIN_DIR") << endl;
        }
42
43
44
45
46
47
48
49
50
        testLoadNMLPlugin();
        cout << "tests passed" << endl;
        return 0;
    } 
    catch (...) 
    {
        cout << "FAILED" << endl;
        return 1;
    }
51
}