--- /dev/null
+#include <assert.h>
+#include <stdbool.h>
+#include <stdlib.h>
+
+#include <drm_fourcc.h>
+#include <libds/allocator/shm.h>
+
+static void
+test_allocator_create(void)
+{
+ struct ds_allocator *alloc = ds_shm_allocator_create();
+ assert(alloc);
+
+ ds_allocator_destroy(alloc);
+}
+
+struct test_data {
+ struct wl_listener destroy;
+ bool called;
+};
+
+static void
+handle_allocator_destroy(struct wl_listener *listener, void *d)
+{
+ struct test_data *data;
+
+ data = wl_container_of(listener, data, destroy);
+ data->called = true;
+}
+
+static void
+test_allocator_events_destroy(void)
+{
+ struct ds_allocator *alloc = ds_shm_allocator_create();
+ assert(alloc);
+
+ struct test_data data = {0, };
+ data.destroy.notify = handle_allocator_destroy;
+ ds_allocator_add_destroy_listener(alloc, &data.destroy);
+
+ ds_allocator_destroy(alloc);
+ assert(data.called == true);
+}
+
+static void
+test_allocator_create_buffer()
+{
+ struct ds_allocator *alloc = ds_shm_allocator_create();
+ assert(alloc);
+
+ struct ds_buffer *buffer = ds_allocator_create_buffer(alloc, 123, 456, DRM_FORMAT_ARGB8888);
+ assert(buffer);
+
+ ds_buffer_drop(buffer);
+ ds_allocator_destroy(alloc);
+}
+
+int
+main(int argc, char *argv[])
+{
+ test_allocator_create();
+ test_allocator_events_destroy();
+ test_allocator_create_buffer();
+ return 0;
+}