Skip to content

Commit

Permalink
Add testing/cudart.cu
Browse files Browse the repository at this point in the history
Add TestCudaMemcpyD2DNullPointerError
Add TestCudaMallocResultAligned

Fixes issue 165.
  • Loading branch information
jaredhoberock committed Sep 2, 2010
1 parent 905712f commit b26325d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions testing/cudart.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <unittest/unittest.h>
#include <cuda_runtime_api.h>
#include <thrust/detail/util/align.h>

void TestCudaMemcpyD2DNullPointerError(void)
{
cudaError_t result1 = cudaMemcpy((void*)0, (void*)0, 1, cudaMemcpyDeviceToDevice);
cudaError_t result2 = cudaGetLastError();

ASSERT_EQUAL(cudaErrorInvalidValue, result1);
ASSERT_EQUAL(cudaErrorInvalidValue, result2);
}
DECLARE_UNITTEST(TestCudaMemcpyD2DNullPointerError);

template<typename T>
void TestCudaMallocResultAligned(const std::size_t n)
{
T *ptr = 0;
cudaMalloc(&ptr, n * sizeof(T));
cudaFree(ptr);

ASSERT_EQUAL(true, thrust::detail::util::is_aligned(ptr));
}
DECLARE_VARIABLE_UNITTEST(TestCudaMallocResultAligned);

0 comments on commit b26325d

Please sign in to comment.