Skip to content

An end-to-end example of testing XTP plugins which call host functions + example mocked host functions.

License

Notifications You must be signed in to change notification settings

dylibso/testing-xtp-plugins

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Testing XTP Plugins with Host Functions

Repository Overview

mock

This directory contains the implementation of the mocked host functions. Note that these functions are Extism plugin exports, which become imports to the plugin that calls the host functions.

plugin

This directory contains an example XTP plugin, based on the schema.yaml schema. It calls the host functions from its export handleLogEvent and aggregates the count of events per event source. We test this plugin's behavior and the host function integration by running it several times with different inputs to see that the KV data and plugin aggregation of that data is correct.

test

This directory contains the test code that calls into the code in plugin to test various aspects of it.

Building

Before compiling the contents, please ensure that you have the following installed:

With all of the above installed, you can now run:

make build

Testing

After you've built the mock, plugin and test modules, you can run:

make test

or:

cd plugin
xtp plugin test # note: the plugin/xtp.toml [[test]] configuration

Questions or need help?

File an issue on this repository, or reach out to us on the Extism Discord and we can provide assistance.