Here's how to run KS-test on $t$-distribution.
- Suppose you have a sample which you suspect is from $t$-distribution, and has size = $n$
- Estimate the t-distribution parameters from the sample.
- Generate $M$ samples of size $n$ from the estimated distribution.
- For each sample obtain KS statistics using the estimated distribution as theoretical
- Build empirical nonparametric distribution from obtained statistics, e.g. using kernel density estimators
- Obtain KS statistics for the original sample and the estimated distribution
- Obtain $p$-value for the KS-stat using the empirical distribution of statistics
- Make decision based on confidence level
In your case d.f. is a given, so you can fit $t$-distribution with a given $N$ instead of estimating it like in my example here in MATLAB ('nu' variable is d.f.).
% True T-distribution
true_pd = makedist('tlocationscale','mu',0,'sigma',1,'nu',2);
% plot true distribution
x=0:0.01:1;
plot(icdf(true_pd,x),x);
hold on;
plot(norminv(x),x);
legend({'t' 'normal'},'Location','Best')
title 'CDF'
rng(0)
% obtain a sample
n=100;
sample = random(true_pd,n,1);
subplot(2,1,1)
histfit(sample,20,'normal');
title 'Sample from t(2,1,0) fit with Nromal'
subplot(2,1,2)
qqplot(sample);

% estimate H_0: T-distribution from this sample
disp 'H_0:'
null_pd = fitdist(sample,'tlocationscale')
[~,~,ksstat] = kstest(sample,'CDF',null_pd);
% get KS-test critical values by parametric bootstrapping from estimated
m=999;
r=random(null_pd,n,m);
stats = zeros(m,1); % store test statistics
est_pd = makedist('tlocationscale');
opts = statset(statset('tlsfit'),'MaxIter',1000);
opts = statset(opts,'MaxFun',2000);
for i=1:m
bsample = r(:,i);
[~,~,stats(i)] = kstest(bsample,'CDF',est_pd.fit(bsample,'options',opts));
end
p = (sum(stats>ksstat)+1) / (m+1);
mcErr = sqrt(p*(1-p)/m);
fprintf('KS stat: %f, p-value: %f, Monte Carlo error: %f\n',ksstat, p , mcErr);
% get the empirical distribution of KS test statistics
epd = ProbDistUnivKernel(stats);
% popular critical values
disp 'Crit. values for \alpha= 0.1, 0.05 and 0.01'
icdf(epd,[ 0.9 0.95 0.99])
figure
plot(icdf(epd,x),x)
grid on
title 'KS-test statistics simulated distribution'

OUTPUT:
H_0:
null_pd =
tLocationScaleDistribution
t Location-Scale distribution
mu = 0.161093 [-0.117585, 0.439771]
sigma = 1.06958 [0.799248, 1.43136]
nu = 1.58744 [1.02505, 2.45837]
KS stat: 0.041646, p-value: 0.865000, Monte Carlo error: 0.010812
Crit. values for \alpha= 0.1, 0.05 and 0.01
ans =
0.0720 0.0791 0.0931
In this case based on $p$-value we can not reject that the sample comes from the t-distribution.
You can compare the critical values with the standard critical values here. You can replace the lines of code where I define and estimate $t$-distribution by the standard normal distribution, and see that the critical values match the table in my link.
If you don't like my method, you can follow this paper, which describes bootstrapping in detail: Jogesh Babu, G., and C. R. Rao. "Goodness-of-fit tests when parameters are estimated." Sankhya: The Indian Journal of Statistics 66 (2004): 63-74.
If you want to see what @Glen_b is talking about when saying that the distribution must be know and not estimated see item #3 here in the NIST Handbook.
It's not a very powerful test if your sample is normal and you have to estimate d.f. It's very difficult to distinguish between normal and $t$-distribution in small sample sizes, because $t$-distribution converges to normal when d.f. N$\to\infty$. In your case N is given, so the test should work fine.